rate_limit_read_timeout

The `rate_limit_read_timeout` directive sets a timeout for reading responses in the Redis backed rate limit module of NGINX.

Syntaxrate_limit_read_timeout timeout;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The rate_limit_read_timeout directive is a parameter of the Redis backed rate limit module for NGINX, which defines the maximum time that the server will wait for a response when reading data from the Redis datastore. This timeout is crucial in scenarios where the application or external service may experience delays, allowing you to control how long the NGINX server waits before timing out the connection to Redis. This helps prevent the server from hanging indefinitely during high load or network issues.

The directive takes a single argument, which is a duration specified in seconds or a time format (e.g., "30s" for 30 seconds). When the read timeout is reached, NGINX will return an error response instead of hanging, enabling better error handling and user experience. This parameter is particularly important for maintaining the responsiveness of your application, as overly long read times can lead to slower overall performance or timeouts for end users.

For effective usage, it's essential to consider the expected response times from Redis based on your application load. For instance, if you anticipate that Redis will respond within 200 milliseconds under normal load conditions, setting a rate_limit_read_timeout of 1 second would be reasonable. However, if you generally see long-running Redis queries, a higher timeout might be needed to accommodate those scenarios without prematurely terminating connections.

Config Example

http {
    # Other configurations...
    rate_limit_read_timeout 30s;
}

Setting this value too low may result in unnecessary timeouts and degraded user experience if Redis experiences normal latency.

In high-load scenarios, ensure that the timeout is calibrated based on observed data retrieval times from Redis to avoid false negatives.

← Back to all directives