fastcgi_buffers decide whether nginx writes the response to disk

an upstream response is buffered to a temporary file is one of the lines people filter out of an nginx error log. It means every response over a certain size is being written to disk and read back before it reaches the client, on a server with memory to spare and no other symptom.

# defaults on a 64-bit build: a 4k header buffer plus 8 × 4k = 36k
fastcgi_buffer_size        4k;
fastcgi_buffers          8 4k;

# so a 60k HTML page goes through /var/lib/nginx/fastcgi_temp, and
# error.log says:
#   an upstream response is buffered to a temporary file
#   /var/lib/nginx/fastcgi_temp/1/00/0000000001 while reading upstream

fastcgi_buffer_size       16k;   # headers only; raise for many cookies
fastcgi_buffers         16 16k;  # 256k of body, per request
fastcgi_busy_buffers_size 32k;

Buffering itself is what you want: it lets PHP-FPM finish and release its worker while nginx feeds a slow client at whatever rate the client manages. Turning it off with fastcgi_buffering off hands that job back to the worker and is the opposite of a fix. fastcgi_buffer_size is a separate allocation for the response header and only needs raising when the headers are unusually large — typically a page setting a great many cookies — while the body goes in fastcgi_buffers. Size them from real responses rather than doubling until the log goes quiet, because the buffers are per request: 16×16k against 500 concurrent connections is a two-gigabyte ceiling. A streaming endpoint is the genuine exception, and it wants buffering disabled in its own location block only.