rate_limit_send_timeout
The `rate_limit_send_timeout` directive sets the timeout duration for sending responses during rate-limiting operations.
Description
The rate_limit_send_timeout directive is part of the Redis-backed rate limiting module for NGINX. This directive establishes a specific timeout period within which the server must successfully send a response when a request exceeds its allowed rate limit. The timeout aims to prevent excessive delays due to prolonged transaction completions, which can occur when dealing with external systems like Redis for rate limiting checks. In practice, if the response cannot be dispatched within the defined duration, NGINX can abort the ongoing send operation to free up resources and potentially handle subsequent requests more efficiently.
Parameters for this directive include a duration specified in standard time formats (e.g., seconds, milliseconds). The directive is integrable at multiple configuration levels (http, server, location), allowing flexibility in defining the timeout behavior tailored to specific contexts or needs. Users must consider network conditions and the responsiveness of their Redis servers when choosing an appropriate timeout value; overly aggressive timeouts could lead to premature aborts, while excessively high values may risk hogging server resources.
Overall, this directive plays a crucial role in maintaining a balance between performance and reliability when managing rate-limited requests involving an external data source.
Config Example
location /api {
rate_limit $limit_key requests=10 period=1m;
rate_limit_send_timeout 1s;
rate_limit_pass redis;
}Setting the timeout too low may lead to excessive aborted requests and could affect user experience negatively.
Ensure proper configuration of the rate limiting backend to avoid timeouts due to high latency responses.
Not all contexts may require a specific timeout, so consider server resource availability.