Nginx · The edge of your stack

How do you tune client and proxy buffers?

Mediumbuffersclient_max_body_sizeproxy_buffer_sizeUpdated Oct 2026
Quiz this track

Short answer

Size request and response buffers for realistic headers and bodies, not extremes. Too-small header buffers cause 502 or 400 errors; too-small body limits cause 413s; oversized buffers waste memory per connection.

Nginx uses buffers to read request headers and bodies and to hold upstream response headers and bodies. Under load, buffer sizes multiply across connections, so tuning is a balance between correctness and memory use.

nginx
client_body_buffer_size 16k;
client_max_body_size 10m;
large_client_header_buffers 4 16k;

proxy_buffer_size 16k;
proxy_buffers 8 16k;
proxy_busy_buffers_size 32k;
proxy_max_temp_file_size 1024m;

Symptoms of bad sizing

  • 413 appears when the request body exceeds client_max_body_size
  • 502 with upstream sent too big header usually means proxy_buffer_size is too small
  • 400 or 414 can indicate request line or header buffers are too small
  • Large request bodies spill to a temp file once client_body_buffer_size is exceeded
  • proxy_busy_buffers_size must be larger than proxy_buffer_size and within the total buffer set
Disabling proxy buffering for streaming is a separate decision. Buffers improve backend connection reuse and absorb slow clients, so do not turn them off globally.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1What causes a 502 with upstream sent too big header?
  2. 2How does client_max_body_size differ from client_body_buffer_size?
  3. 3When does Nginx write a request body to disk?
  4. 4Why can oversized buffers hurt at high concurrency?

Say it in the interview

I size buffers from observed header and body sizes. The most common issues are a 413 when client_max_body_size is too low and a 502 with upstream sent too big header when proxy_buffer_size cannot hold response headers. I keep buffers moderate because they consume memory per connection. For streaming endpoints I disable buffering only there, not globally.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Nginx mock interview and get scored feedback on depth, clarity and confidence.