“This is the 7th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

directory

  • The problem
  • To solve
    • proxy_buffer_size
    • proxy_buffers
    • proxy_busy_buffers_size
  • At the end

The problem

In the previous article, we described how to resolve the net::ERR_CONTENT_LENGTH_MISMATCH 206 (Partial Content) problem by modifying the cache size of the Nginx proxy service as follows:

proxy_buffer_size 128k;

proxy_buffers 32 128k;

proxy_busy_buffers_size 128k;

Many people ask, what are the functions of these three configuration items? We’re going to find out today.

To solve

Next, let’s analyze them separately.

proxy_buffer_size

The syntax of proxy_buffer_SIZE is as follows:

proxy_buffer_size size

The default value of proxy_buffer_size is 4K or 8K, which specifies the size of the nginx read cache. Nginx uses proxy_buffer_size to apply read_buf to upstream header. If the response header exceeds this length, Upstream: sent too big header upstream: sent too big header upstream: sent too big header We set this value to 128K to ensure an adequate read cache size.

proxy_buffers

The syntax of the proxy_buffers configuration item is as follows:

Proxy_buffers quantity size

The default value of proxy_buffers is 256 8K. This sets the number of buffers and the size of each buffer that will be used to store the body of the proxy server response. By default, 256 8K read_buf buffers are created to store the body, but instead of 256 buffers being created when the connection is established, a new buffer is requested if the current buffer is not large enough to store the body of the response. A maximum of 256 buffers can be applied. After the modification, the total buffer size is doubled from the default value.

proxy_busy_buffers_size

The syntax of proxy_busY_buffers_size is as follows:

proxy_busy_buffer_size  size

Proxy_busy_buffer_size has no separate default value, it is not a separate space, it is actually part of proxy_buffers and proxy_buffer_size. Nginx will start sending data to the client without fully reading the response data from the back end, so it will allocate a portion of the busy buffer to send data to the client exclusively (recommended to be twice the size of a single buffer in proxy_buffers), and then continue fetching data from the back end. The proxy_busY_buffer_size parameter sets the size of the buffer in the busy state. If the full data size is smaller than the busy_buffer size, the data is transferred to the client immediately after the transfer is complete. If the full data size is at least busy_buffer, the busy_buffer is filled and immediately passed to the client.

At the end

That concludes today’s discussion of nginx’s three cache configuration items (proxy_buffer_size, proxy_buffers, and proxy_busy_buffers_size). I believe that even if you do not fully understand, but also more or less gain.

About the author: Hello, everyone, I am Liuzhen007, an audio and video technology fan, CSDN blog expert, Huawei Cloud community cloud sharing expert, signed the author, welcome to follow me to share more dry products!