uwsgi_limit_rate
The `uwsgi_limit_rate` directive limits the rate of data sent to a uWSGI server.
Description
The uwsgi_limit_rate directive is used to control the maximum transfer speed for responses to clients in an NGINX web server context. By specifying a rate in bytes per second, administrators can implement bandwidth throttling, which is useful for managing server resources and ensuring that one client's usage does not adversely affect others. This directive is specifically designed for use with uWSGI, which is a gateway interface protocol used to serve Python web applications.
When uwsgi_limit_rate is set, NGINX will restrict the rate at which it sends data to the client, adjusting the output to match the defined limit. The directive accepts one argument, which is the maximum speed at which data should be sent (for example, 200k for 200 kilobytes per second). It can be placed within different contexts, including http, server, or location, allowing granular control over which requests it applies to.
Keep in mind that when rates are limited, it can affect the performance of applications served by uWSGI, especially under high load or with large responses. The directive is particularly beneficial in situations where there are multiple consumers of the same server resource or when limiting usage to avoid spikes in bandwidth consumption.
Config Example
http {
server {
location / {
uwsgi_pass myapp;
uwsgi_limit_rate 500k;
}
}
}Setting uwsgi_limit_rate too low may result in poor user experience due to slow response times.
Ensure that the rate is specified correctly; otherwise, NGINX may ignore the directive.
Higher limits may not have a noticeable effect if the application itself has lower output speeds.