http2_recv_buffer_size

Sets the size of the receive buffer for HTTP/2 connections in NGINX.

Syntaxhttp2_recv_buffer_size size;
Defaultnone
Contexthttp
Arguments1

Description

The http2_recv_buffer_size directive in NGINX is used to specify the size of the buffer allocated for processing incoming HTTP/2 traffic. This directive is crucial for optimizing the server's ability to handle various types of requests, especially when dealing with multiple concurrent connections typical in HTTP/2 communications. By default, the value is not set, which can lead to either low performance under high loads or excessive memory usage if set too high. Therefore, it is important to balance the buffer size according to anticipated traffic patterns and server resources.

When this directive is defined, it accepts a single size argument which can be specified in bytes, kilobytes, or megabytes (e.g., 1m for 1 megabyte). The buffer is utilized primarily when reading incoming data from the client, establishing a controlled environment for managing HTTP/2 frames transmitted over the connection. Setting this buffer too small may result in a drop in performance or additional latency, as the server will require more frequent reads from the socket. Conversely, a buffer that is too large may waste server memory resources, especially with a high number of connections. Hence, careful consideration should be given to the optimal buffer size for each server depending on its load expectations and available resources.

Config Example

http {
    http2_recv_buffer_size 256k;
}

Ensure that the buffer size is appropriately set to match expected traffic volume; too small can lead to performance issues, too large can waste memory.

Misconfiguration may lead to unexpected server behavior or resource exhaustion under load.

← Back to all directives