rate_limit_connect_timeout
Sets the timeout for receiving a connection response when using Redis for rate limiting.
Description
The rate_limit_connect_timeout directive in the Redis-backed rate limit module for NGINX specifies the maximum time, in seconds, for establishing a connection to the Redis server used for rate limiting. This value pertains directly to how long NGINX will attempt to connect to the Redis instance when a request exceeds configured rate limits. An appropriate timeout is crucial, as it ensures that users do not experience excessive delays in response due to connectivity issues with Redis. If the timeout is reached and a connection is still not established, NGINX will return an error response instead of continuing to wait.
The directive can be configured in the http, server, or location contexts, allowing flexibility depending on the configuration requirements. As it accepts a single argument, the specified timeout duration should be an integer value representing the number of seconds. For instance, a value of 5 would set the timeout to five seconds, meaning NGINX will give up on connecting to Redis after this duration without successfully establishing a connection. This is particularly beneficial in production environments where connection delays could severely impact user experience.
Config Example
rate_limit_connect_timeout 5;
Ensure that the timeout value is appropriately set to balance between performance and user experience.
Setting the timeout too low may result in frequent connection errors if Redis is not responsive under load.
This directive must be used in conjunction with the Redis-backed rate limit setup; otherwise, it has no effect.