proxy_downstream_buffer

The proxy_downstream_buffer directive controls the buffering of data received from upstream servers in the NGINX stream module.

Syntaxproxy_downstream_buffer size;
Defaultnone
Contextstream, stream server
Arguments1

Description

The proxy_downstream_buffer directive configures the buffering behavior for responses received from upstream servers in a TCP/UDP stream context. By specifying a size as the argument, this directive determines how much data is held in memory before being sent downstream to the client. If the size is set too low, clients may experience interruptions during data delivery as NGINX would have to wait for more data to be received from the upstream before it can send it out. Conversely, setting the buffer size too high can consume excessive memory resources, potentially driving up resource usage and causing other performance issues.

This directive is specifically useful in scenarios where the data flow is high or the connection rates are unpredictable, as it can help stabilize delivery to clients during spikes in traffic. As the proxy_downstream_buffer is applied contextually within stream and stream server, it allows fine-tuning of resource allocation per each defined stream. The directive's effectiveness can be influenced by other settings related to rates, timeouts, and memory limits, and adjustments should be made mindfully to prevent unintended side effects during peak load periods.

Config Example

stream {
    upstream my_upstream {
        server 192.168.1.1:1234;
    }
    server {
        listen 1234;
        proxy_pass my_upstream;
        proxy_downstream_buffer 64k;
    }
}

Setting the buffer size too high can lead to increased memory usage.

If the buffer size is too low, it may cause delivery delays or interruptions for the client.

Ensure that the directive is used in the correct context (stream or stream server).

← Back to all directives