nchan_redis_reconnect_delay_max
Sets the maximum delay for reconnection attempts to Redis when using Nchan.
Description
The nchan_redis_reconnect_delay_max directive configures the maximum delay to be used when attempting to reconnect to a Redis server after a connection failure. This directive is primarily relevant in environments where Nchan, as a pub/sub server, integrates with Redis for message buffering and delivery. When Redis becomes unavailable, Nchan uses exponential backoff to manage reconnection attempts. The time between attempts increases, up to the limit set by this directive, to avoid overwhelming the Redis service during temporary unavailability.
In practical terms, if the connection to Redis fails, the Nchan module will wait for a shorter delay initially but will increase this delay exponentially until it reaches the maximum specified by nchan_redis_reconnect_delay_max. For instance, if the maximum delay is set to 60 seconds, the reconnection timer will not exceed this duration between reconnection attempts. This ensures that the system behaves gracefully under failure conditions, allowing other processes to take place while avoiding immediate and constant reconnect attempts that could lead to denial of service.
The directive is specified with a single argument, which must be a time duration. It is applicable in the upstream context, where the Redis server can be defined. Correct configuration will ensure that Nchan efficiently manages its interactions with Redis, adapting to changes in availability without manual intervention.
Config Example
upstream redis_backend {
nchan_redis_reconnect_delay_max 30s;
server redis-server:6379;
}Make sure the time value is in a recognized format (e.g., 30s, 1m).
Incorrect placement of this directive can lead to it being ignored; ensure it is within the upstream context.
Setting an excessively high value can delay recovery from Redis outages. Consider the trade-off between connection frequency and load.