zstd_buffers

Sets the number and size of buffers used by the Zstandard compression filter in NGINX.

Syntaxzstd_buffers number size;
Defaultnone
Contexthttp, server, location
Arguments2

Description

The zstd_buffers directive in the NGINX Zstandard module specifies the buffer setup required for handling data during the Zstandard compression process. It takes two arguments: the first is the number of buffers to allocate, and the second specifies the size of each buffer. This configuration essentially determines how much memory will be reserved for compressing response data before it is sent to the client. Having appropriately sized and sufficiently allocated buffers can significantly impact the performance during high-throughput situations, as they ensure smooth data handling and flow through the compression pipeline.

When setting the zstd_buffers, users must consider the expected size of the responses being compressed and the available memory resources. If set too low, the buffers may become a bottleneck, leading to increased response times and potential memory shortages when handling larger responses. Conversely, setting the buffer size too high could lead to excessive memory usage without significant performance advantages. This balance is a crucial aspect of configuring NGINX for optimal performance with Zstandard compression, especially under varying load conditions.

Config Example

http {
    zstd_buffers 16 4k;  
}
server {
    location / {
        zstd on;
        zstd_buffers 8 8k;
    }
}

Ensure that the buffer size is appropriate for the expected response sizes; otherwise, you may face memory constraints or inefficient compression performance.

Misconfiguring the number of buffers can lead to overuse of memory or underutilization, affecting overall server performance.

← Back to all directives