nchan_redis_reconnect_delay

Sets the delay in seconds for reconnecting to Redis when a connection is lost in Nchan's Redis-backed pub/sub setup.

Syntaxnchan_redis_reconnect_delay seconds;
Defaultnone
Contextupstream
Arguments1

Description

The nchan_redis_reconnect_delay directive specifies the amount of time, in seconds, that Nchan will wait before attempting to reconnect to a Redis server after a connection failure. This is particularly useful in environments where Redis is used as a message broker for pub/sub functionality. By introducing a delay before reconnection efforts, the directive helps to prevent overwhelming the Redis server with excessive connection attempts, especially in scenarios where the Redis server may be temporarily unavailable due to network issues or high load.

When set, if Nchan detects that the connection to Redis has been lost, it will pause for the designated duration before retrying the connection. During this time, subscriber connections may be temporarily disrupted, but they can be automatically reestablished once the Redis connection is successfully restored. This configuration helps maintain the health of the application and ensures that resources are managed efficiently, especially in high-traffic situations where rapid reconnections could otherwise lead to resource exhaustion.

The directive takes a single argument which should be a numeric value representing the delay in seconds. It should be placed within the upstream context where Redis is configured for use with Nchan. Failure to specify realistic values might lead to either long downtimes or excessive load on Redis if set too low.

Config Example

upstream redis {
    server localhost:6379;
    nchan_redis_reconnect_delay 5;
}

Setting the reconnect delay too short can lead to excessive connection attempts and overload Redis.

If the delay is set too long, clients may experience longer waits before being able to process messages after a Redis outage.

← Back to all directives