proxy_download_rate

The `proxy_download_rate` directive controls the rate of data transfer for proxied streams.

Syntaxproxy_download_rate rate;
Defaultnone
Contextstream, stream server
Arguments1

Description

The proxy_download_rate directive is utilized within the NGINX Stream module to limit the rate at which data is sent to clients over a proxied stream connection. This can be particularly useful in scenarios where you want to control bandwidth usage or ensure fair resource allocation among multiple clients. The argument for this directive is a numerical value that specifies the maximum data transfer rate in bytes per second.

When the directive is set, NGINX applies this limit to the downloads initiated by the proxy, making it easier to manage the total load on the server and optimize performance. It works by monitoring the data packets being sent to the client and adjusting the flow if the transfer rate exceeds the specified limit. This can prevent network saturation and improve user experience by distributing bandwidth more evenly, especially during peak usage times. Importantly, this directive can be set globally or tailored specifically for individual stream servers depending on the unique requirements of each service.

To implement proxy_download_rate, the directive must be placed within the stream context or inside a stream server block. It is also essential to note that this directive is only applicable when acting as a proxy for streams, and its effects may vary depending on other network configurations in use.

Config Example

stream {
    server {
        listen 12345;
        proxy_pass backend_server;
        proxy_download_rate 1024;  # Limit download rate to 1KB/s
    }
}

Setting this directive to a very high value may lead to unintentional bandwidth hogging, affecting other services.

Ensure that your backend service can handle the connections as per the set download rate to avoid bottlenecks.

← Back to all directives