Write a speed-limit module, any suggestion?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Write a speed-limit module, any suggestion?

vedranf
I want to write a module to transfer files to client, but it need to limit the speed of transfer.
how can i implement it ?

it is likely that i should output one buffer per time, and then check the avg speed before, if expire the setting speed what should i do then?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,4234,4234#msg-4234


Reply | Threaded
Open this post in threaded view
|

Re: Write a speed-limit module, any suggestion?

Gabriel Ramuglia
There is a rate limit option you can set if you are using reproxy_url.
There's a header you can set that is supposed to limit the rate of the
download to whatever you set. So I would look over the documentation
for reproxy_url and see if that will work for you.

On Sun, Jul 19, 2009 at 11:46 PM, supergui<[hidden email]> wrote:
> I want to write a module to transfer files to client, but it need to limit the speed of transfer.
> how can i implement it ?
>
> it is likely that i should output one buffer per time, and then check the avg speed before, if expire the setting speed what should i do then?
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,4234,4234#msg-4234
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Write a speed-limit module, any suggestion?

Grzegorz Sienko
Something like this? http://wiki.nginx.org/NginxHttpCoreModule#limit_rate

2009/7/20 Gabriel Ramuglia <[hidden email]>:

> There is a rate limit option you can set if you are using reproxy_url.
> There's a header you can set that is supposed to limit the rate of the
> download to whatever you set. So I would look over the documentation
> for reproxy_url and see if that will work for you.
>
> On Sun, Jul 19, 2009 at 11:46 PM, supergui<[hidden email]> wrote:
>> I want to write a module to transfer files to client, but it need to limit the speed of transfer.
>> how can i implement it ?
>>
>> it is likely that i should output one buffer per time, and then check the avg speed before, if expire the setting speed what should i do then?
>>
>> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,4234,4234#msg-4234
>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Write a speed-limit module, any suggestion?

vedranf
In reply to this post by Gabriel Ramuglia
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?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,4234,4304#msg-4304