nchan_redis_reconnect_delay_jitter

The `nchan_redis_reconnect_delay_jitter` directive introduces a random jitter to the reconnection delay when establishing a connection to a Redis server in Nchan.

Syntaxnchan_redis_reconnect_delay_jitter number;
Defaultnone
Contextupstream
Arguments1

Description

The nchan_redis_reconnect_delay_jitter directive is used in the context of Nchan, a scalable pub/sub server for NGINX that allows buffering messages across multiple subscribers via Redis. When the Nchan module attempts to reconnect to a Redis server after a disconnection, it typically follows a standard exponential backoff strategy to prevent overwhelming the server with connection attempts. This directive adds randomness to the delay mechanism, allowing for a jitter effect that helps distribute reconnection attempts over time, which can be particularly useful in scenarios where multiple Nchan instances are trying to reconnect to the same Redis server simultaneously.

The parameter for this directive specifies the amount of random jitter to apply to the reconnection delay. By introducing this randomness, it can prevent a thundering herd problem, where all Nchan instances try to connect at the same time, causing intermittent overload or latency on the Redis server. The behavior can significantly improve connection robustness and overall performance, particularly in environments with high availability configurations or during maintenance periods where Redis may be temporarily unavailable.

Config Example

upstream my_redis {
    nchan_redis_reconnect_delay_jitter 100; 
}

Ensure that the provided jitter value is appropriate for your environment to avoid excessively long connection delays.

Using a very high jitter value can lead to increased latency in reconnection attempts.

← Back to all directives