March 1st, 2017
(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: email@example.com
I’ve been struggling with a slow NodeJS app which is behind a reverse proxy handled by Nginx.
Syntax: proxy_max_temp_file_size size; Default: proxy_max_temp_file_size 1024m; Context: http, server, location When buffering of responses from the proxied server is enabled, and the whole response does not fit into the buffers set by the proxy_buffer_size and proxy_buffers directives, a part of the response can be saved to a temporary file. This directive sets the maximum size of the temporary file. The size of data written to the temporary file at a time is set by the proxy_temp_file_write_size directive. The zero value disables buffering of responses to temporary files.
1) How can I remove the [warn] and avoid buffering responses? Is it better to turn off proxy_buffering or set proxy_max_temp_file_size to 0? Why?
You should set proxy_max_temp_file_size to 0 in order to remove it. The proxy_buffering directive isn’t directly related to the warning. You can switch it off to stop any buffering at all but that isn’t recommended in general (unless it’s needed for Comet).
2) If nginx buffers a response when does it serve the buffered response, to whom and why?
It servers immediately, but a client usually has much slower connection and can’t consume the response data as fast as it produced by your application. Nginx tries to buffer the whole response in order to release your application ASAP.