unzstd_buffers
Configures the number and size of buffers used for decompressing zstd-encoded responses in NGINX.
Description
The unzstd_buffers directive specifies how many buffers and the size of each buffer that the NGINX server will use when decompressing responses encoded with Zstandard (zstd) for clients that do not support it. This directive is especially essential for optimizing memory usage and performance when handling compressed response data, as it determines how much data can be processed at a time during the decompression process.
When the NGINX server receives a response with the 'Content-Encoding: zstd' header, and if it is configured to decompress such responses, the unzstd_buffers directive will define the allocation of memory buffers. These buffers are crucial for temporarily storing the decompressed data as it is being processed before it is delivered to the client. Users can configure this directive in the contexts of http, server, and location, which allows for flexibility depending on the server's needs.
Parameters for this directive include two values: the first value specifies the number of buffers, while the second value indicates the individual size of each buffer. For instance, setting unzstd_buffers 32 4k; allocates 32 buffers with a size of 4 kilobytes each. The directive should be set carefully based on server performance and traffic characteristics, as incorrect settings may lead to inefficient memory utilization or failures in handling large responses.
Config Example
server {
listen 127.0.0.1:8080;
server_name localhost;
location / {
unzstd on;
unzstd_buffers 32 4k;
proxy_pass http://foo.com;
}
}Setting too few buffers may lead to decompression errors for large responses.
Using buffer sizes larger than the available memory may lead to performance degradation.
If the unzstd directive is not enabled, this directive will have no effect.