nchan_redis_upstream_stats_disconnected_timeout
Sets the timeout for a disconnected Nchan Redis upstream server in seconds.
Description
The nchan_redis_upstream_stats_disconnected_timeout directive in Nginx's Nchan module is used to set the duration (in seconds) that a disconnected upstream Redis server will be retained in the connection pool. This is particularly useful in scenarios where Redis upstream servers may become temporarily unavailable due to network issues, maintenance, or other transient problems. By specifying a timeout, administrators can effectively manage how long the server instance remains cached in the pool despite being disconnected, therefore influencing the failover and reconnection behavior of Nchan when relying on Redis for pub/sub messaging.
The parameter for this directive is a number denoting the number of seconds. If the number of seconds has elapsed while the Redis server is still disconnected, Nchan will remove this server from the connection pool, stopping attempts to connect to it until a new connection is explicitly defined or another server takes its place. This feature helps in maintaining smooth operation and responsiveness of the messaging system by preventing prolonged attempts to reconnect to unresponsive servers. It is especially critical in high availability setups where performance latency could affect client subscriptions and message delivery.
Config Example
upstream redis_backend {
server redis1.example.com:6379;
server redis2.example.com:6379;
nchan_redis_upstream_stats_disconnected_timeout 30;
}Ensure that the timeout is reasonable to avoid unnecessary disconnection of active Redis servers during brief outages.
Setting the timeout too low might lead to frequent reconnection attempts, which could increase load on the Redis server.