scgi_buffer_size

Defines the size of the buffer used for reading the first part of the response from an SCGI server.

Syntaxscgi_buffer_size size;
Default4k
Contexthttp, server, location
Arguments1

Description

The scgi_buffer_size directive in NGINX is crucial for managing how much data can be buffered from an SCGI server's response before further processing occurs. When NGINX communicates with an SCGI backend, it expects the response to arrive in manageable chunks. By specifying scgi_buffer_size, you control the buffer allocated for the initial part of this response, which includes the SCGI headers. Efficient management of this buffer size can greatly impact the performance of your application, especially if the responses have variable sizes.

The directive accepts a single argument that defines the size of the buffer. If the server sends a response larger than this buffer size, NGINX will allocate additional buffers as needed to accommodate the entire response. It's vital to set this value based on an understanding of the typical size of SCGI responses your application generates. A too-small buffer might lead to unnecessary memory allocations, while an excessively large buffer could waste resources and reduce performance. Hence, tuning this parameter according to actual usage patterns can lead to improved resource utilization and performance stability.

Config Example

location /app {
    scgi_pass 127.0.0.1:9000;
    scgi_buffer_size 8k;
}

Setting the buffer size too small can lead to performance issues due to frequent memory allocations.

If the size is set too large, it may waste memory resources, especially under high load conditions.

Changes to this directive may not take effect until NGINX is reloaded or restarted, requiring careful deployment practices.

← Back to all directives