# Nginx won't honor limit\_rate

**URL:** <https://www.ruby-forum.com/t/nginx-wont-honor-limit-rate/212305>\
**Category:** NGINX\
**Created:** [September 29, 2011, 1:07am UTC](https://www.ruby-forum.com/t/nginx-wont-honor-limit-rate/212305 "2011-09-29T01:07:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [September 29, 2011, 1:07am UTC](https://www.ruby-forum.com/t/nginx-wont-honor-limit-rate/212305/1 "2011-09-29T01:07:11Z")

</div>

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:

> **[nginx won't honor limit\_rate](https://forum.nginx.org/read.php?2,215989,215989#msg-215989)**
>
> 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 does

---

<div class="post-metadata">

**Author:** ![mojiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mojiz](https://www.ruby-forum.com/u/mojiz)\
**Post date:** [September 29, 2011, 1:24am UTC](https://www.ruby-forum.com/t/nginx-wont-honor-limit-rate/212305/2 "2011-09-29T01:24:06Z")

</div>

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 [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/Debugging).

Maxim D.

---

<div class="post-metadata">

**Author:** ![mojiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mojiz](https://www.ruby-forum.com/u/mojiz)\
**Post date:** [September 29, 2011, 1:32am UTC](https://www.ruby-forum.com/t/nginx-wont-honor-limit-rate/212305/3 "2011-09-29T01:32:05Z")

</div>

Thanks Max.  
It worked!

Posted at Nginx Forum:

> **[Re: nginx won't honor limit\_rate](https://forum.nginx.org/read.php?2,215989,215991#msg-215991)**
>
> 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 does

---

<div class="post-metadata">

**Author:** ![mojiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mojiz](https://www.ruby-forum.com/u/mojiz)\
**Post date:** [September 30, 2011, 11:19am UTC](https://www.ruby-forum.com/t/nginx-wont-honor-limit-rate/212305/4 "2011-09-30T11:19:23Z")

</div>

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  
> > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)
> 
> –

---

<div class="post-metadata">

**Author:** ![mojiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mojiz](https://www.ruby-forum.com/u/mojiz)\
**Post date:** [September 30, 2011, 10:23am UTC](https://www.ruby-forum.com/t/nginx-wont-honor-limit-rate/212305/5 "2011-09-30T10:23:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mojiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mojiz](https://www.ruby-forum.com/u/mojiz)\
**Post date:** [September 30, 2011, 5:13pm UTC](https://www.ruby-forum.com/t/nginx-wont-honor-limit-rate/212305/6 "2011-09-30T17:13:47Z")

</div>

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

Posted at Nginx Forum:

> **[Re: nginx won't honor limit\_rate](https://forum.nginx.org/read.php?2,215989,216112#msg-216112)**
>
> 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 does

---

<div class="post-metadata">

**Author:** ![mojiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mojiz](https://www.ruby-forum.com/u/mojiz)\
**Post date:** [September 30, 2011, 4:57pm UTC](https://www.ruby-forum.com/t/nginx-wont-honor-limit-rate/212305/7 "2011-09-30T16:57:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mojiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mojiz](https://www.ruby-forum.com/u/mojiz)\
**Post date:** [September 30, 2011, 5:18pm UTC](https://www.ruby-forum.com/t/nginx-wont-honor-limit-rate/212305/8 "2011-09-30T17:18:43Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > > 
> > > > [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)
> > 
> > * * *
> > 
> > nginx mailing list  
> > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)
> 
> –

---

<div class="post-metadata">

**Author:** ![mojiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mojiz](https://www.ruby-forum.com/u/mojiz)\
**Post date:** [September 30, 2011, 6:14pm UTC](https://www.ruby-forum.com/t/nginx-wont-honor-limit-rate/212305/9 "2011-09-30T18:14:54Z")

</div>

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.
