proxy_upload_rate
The proxy_upload_rate directive controls the maximum upload rate for proxied connections in NGINX Stream.
Description
The proxy_upload_rate directive in the NGINX Stream module specifies the maximum upload rate for connections that are proxied. This directive allows for bandwidth shaping, which is useful in scenarios where you want to limit the upload speed to prevent any individual user from hogging the available bandwidth. The value is typically defined in bytes per second, which directly impacts the overall performance of the upload activities on the server.
When configured, if a connection attempts to upload data faster than the defined rate, NGINX will pause the transmission to enforce the bandwidth limit. This can help with balancing load across multiple users and maintaining service quality for all connections. The directive can be applied in the stream or stream server context, thus allowing for flexible configurations across multiple server instance scenarios.
It is important to note that the specified upload rate should reflect realistic limits that consider your server's capabilities and the expected workloads. Carefully testing different values in a staging environment before deployment is advisable to find the optimal configuration balance. Additionally, exceeding very high values for upload rates can introduce performance issues due to the high overhead on the network stack.
Config Example
stream {
server {
listen 12345;
proxy_pass backend_server;
proxy_upload_rate 1m;
}
}Ensure the rate value is realistic to avoid performance issues.
The directive may not apply as expected if upstream servers do not handle backpressure well. Additionally, using this directive without proper tuning can lead to underutilization of bandwidth, so careful consideration of the settings is essential.