scgi_request_buffering

The `scgi_request_buffering` directive controls buffering of SCGI requests in NGINX.

Syntaxscgi_request_buffering on | off;
Defaulton
Contexthttp, server, location
Argumentsflag

Description

The scgi_request_buffering directive specifies whether to enable or disable buffering of SCGI request bodies. When buffering is turned on (set to on), NGINX will read the entire request body into memory before passing it to the SCGI server. This can improve performance by allowing NGINX to handle the request body in a single operation. However, it also increases memory usage because larger request bodies may exceed available memory limits or consume excessive resources when many concurrent requests are made.

When buffering is disabled (set to off), NGINX will pass the request body to the SCGI server in chunks as they are received. This minimizes memory usage and is suitable for scenarios where clients send large amounts of data, such as file uploads, as it allows the server to start processing the data as soon as it begins receiving it. Choosing the appropriate setting for this directive may depend on the characteristics of the application and the types of requests being processed.

The directive can be applied within various contexts, including http, server, and location, allowing for flexible configuration based on specific routing or handling rules. Proper use of scgi_request_buffering is essential for optimizing resource management and ensuring responsive application performance.

Config Example

location /scgi {
    scgi_pass 127.0.0.1:4000;
    scgi_request_buffering off;
}

If memory constraints are an issue, disabling buffering might be necessary, but be aware that performance can be affected.

Improperly setting this directive can lead to unexpected results, especially in applications that rely on processing the entire request body before any response is sent.

← Back to all directives