Nginx won't honor limit_rate

Hi

I have an nginx server
nginx version: nginx/1.1.2
I’m using limit_rate to limt download speed of my users however after an
upgrade(I can’t remember the version)
it doesn’t work anymore.
Do you know why or how can I debug this?
The debug log doesn’t show anything.
BTW I’m using nginx_proxy to send a file from my backends to my users.
I have used X-Accel-Limit-Rate, limit_rate and $limit_rate but neither
worked

Regards

Posted at Nginx Forum:

Hello!

On Wed, Sep 28, 2011 at 07:06:56PM -0400, mojiz wrote:

I have used X-Accel-Limit-Rate, limit_rate and $limit_rate but neither
worked

Most likely you are using “proxy_buffering off;”, it disables any
buffering including limit_rate one.

If in doubt, please follow Debugging | NGINX.

Maxim D.

Thanks Max.
It worked!

Posted at Nginx Forum:

Hello!

On Fri, Sep 30, 2011 at 04:22:52PM +0800, li zJay wrote:

set “proxy_buffering on”, the upstream response may touch the disk
this suffers a lot when nginx is used as a proxy to file download servers.

If you want nginx to don’t touch disk, use

proxy_max_temp_file_size 0;

instead. This will still allow in-memory buffering and wouldn’t
touch disk.

Maxim D.

nginx mailing list
[email protected]
nginx Info Page

set “proxy_buffering on”, the upstream response may touch the disk
this suffers a lot when nginx is used as a proxy to file download
servers.

What exactly do you mean by ‘suffer’?
I’m using limit_rate to slow the user downloads.

Posted at Nginx Forum:

hello!

If you want nginx to don’t touch disk, use

proxy_max_temp_file_size 0;

instead. This will still allow in-memory buffering and wouldn’t
touch disk.

Because the client bandwidth is usually slow, in this case, tons of
upstream
content will be buffer in memory before sent out to client, and then the
swap will be used and the server is going down soon.

Hello!

On Fri, Sep 30, 2011 at 10:56:41PM +0800, li zJay wrote:

Because the client bandwidth is usually slow, in this case, tons of upstream
content will be buffer in memory before sent out to client, and then the
swap will be used and the server is going down soon.

The limit on memory usage for proxy buffering is set with
proxy_buffers directive, 8 * pagesize by default. Nobody stops
you from setting it even lower if you are memory-constrained.

The “proxy_buffering off;” is needed when you want response to be
immediately passed to clients once it arrives. It’s critical for
streaming and similar workloads where you can’t afford delays.
But it’s not a switch to limit resource consumption. Instead, it
actually implies less effective resource usage: processing of
requests without buffering takes more CPU time and may cause
suboptimal network utilization.

Maxim D.

On Thu, Sep 29, 2011 at 7:31 AM, mojiz [email protected] wrote:

nginx Info Page


nginx mailing list
[email protected]
nginx Info Page

Thanks Maxim D.!

I thought that if proxy_max_temp_file_size is set to 0, all the upstream
content have to be buffered in memory, and I make a test and find I’m
wrong.