Thanks very much Grzegorz Sienko. But perhaps there is some differences of my case, i have to change the rate at running time, that is i have to control the rate in my own module code. And i have my own file system to read file, so i have to do every thing from reading file from my file system to write stream at controled rate to the client. I have just found there is a timer in nginx that maybe do help for me, that is i write a buffer to client and check the rate, if expire i just need to add a timer to be called to continue after a piece of time(e.g 100ms), and then write next buffer. Repeatly do that, untill i write the total file.
But i have some difficulties in the timer, i add a test timer to it ,but it never run my handler?