How do proxy_module response buffering options work?

Hongli Lai lists at
Sun Apr 24 18:49:23 MSD 2011

I'm trying to understand how the different proxy_module response
buffering options work. The current documentation is a little bit vague.
Here's how I currently think buffering works:

Nginx allocates a number of separate buffers for buffering the response.
They are probably used as a ring for efficiency reasons.

The first buffer is used to store the response header, and must be large
enough to store the header. I'm guessing this is because the proxy
module's response header parser can only operate on a contiguous block
of memory. The size of this first buffer can be customized through
proxy_buffer_size, but it has no effect on all the other buffers.

If proxy_buffering is turned on then Nginx will fill all proxy buffers
with data, either until the upstream sends EOF or until the buffers are
full. When one of those conditions occur Nginx will flush the data to
the client. If the client does not read data quickly enough Nginx will
write the unflushed buffer data to disk and will flush them when the
client can read more data. This is repeated until the upstream sends

If proxy_buffering is turned off then Nginx will also fill all proxy
buffers. However it tries to immediately flush the data to the client.
If the upstream sends data faster than the client can read then the
proxy buffers will eventually be full and upstream will be throttled
until the client can read more data.

Is this correct? There's also proxy_busy_buffers_size but I have no idea
what that is.

Posted via

More information about the nginx mailing list