nchan_redis_idle_channel_keepalive_min
The nchan_redis_idle_channel_keepalive_min directive sets the minimum keepalive time for idle channels in Redis for the Nchan module.
Description
The nchan_redis_idle_channel_keepalive_min directive is used within the context of upstream to define the minimum amount of time a channel should remain active in the Redis backend before being considered idle and potentially eligible for cleanup. When subscribed clients disconnect without explicitly unsubscribing, their associated channels may still exist in Redis, holding onto memory. This directive ensures that these channels are retained for a minimum period, allowing for any reconnects from clients or continuation of activity before they are purged from memory. It is particularly important in high-traffic scenarios where frequent connect/disconnect patterns can result in excessive memory churn if channels are cleaned up too aggressively.
The parameter accepted by this directive is a time value that specifies the duration in seconds. Setting this value appropriately can help balance the trade-off between memory usage and performance. A very low value may lead to premature eviction of channels, hurting user experience if subscribers try to reconnect shortly after the channels have been removed. On the other hand, a very high value can result in increased memory consumption due to retained channels that are no longer needed. Administrators should analyze their specific application workload and subscriber behaviors to fine-tune this setting effectively.
Config Example
upstream nchan {
nchan_redis_idle_channel_keepalive_min 5s;
}Setting the value too low can lead to frequent channel deletions, which may disrupt user experience by requiring clients to frequently re-establish subscriptions.
Using this directive in a context other than upstream will result in an configuration error.