nchan_redis_idle_channel_keepalive_max

Configures the maximum idle duration for Redis channels in Nchan for greater efficiency in resource utilization.

Syntaxnchan_redis_idle_channel_keepalive_max time;
Defaultnone
Contextupstream
Arguments1

Description

The nchan_redis_idle_channel_keepalive_max directive is used within the context of upstream configuration for the Nchan module in NGINX, specifically when leveraging Redis for message broadcasting. This directive controls the maximum idle duration that a Redis channel can exist without being actively used before it is considered for cleanup. By specifying this value, users can manage system resources more effectively, as long-standing idle channels may unnecessarily consume memory and operational overhead in Redis.

When activated, if a channel exceeds the configured idle duration, it becomes eligible for removal from Redis, facilitating the release of resources that are no longer needed. This is particularly useful in high-traffic environments where many channels may be created dynamically by publishers or subscribers and, due to sporadic interactions, may remain idle for extended periods.

The value for this directive is specified in seconds and can be uniquely customized per upstream context, allowing for adjustments based on specific application requirements. Proper adjustment can lead to enhanced performance and stability by preventing Redis from being overwhelmed with orphaned channels that are no longer in use.

Config Example

upstream my_backend {
    nchan_redis_idle_channel_keepalive_max 300;
}

Setting the value too high can lead to unnecessary resource consumption by unused channels in Redis.

Conversely, setting the value too low may result in frequent channel removals, impacting the ability to maintain persistent connections.

← Back to all directives