nchan_redis_idle_channel_cache_timeout

Sets the timeout for caching idle channels in Redis used by Nchan.

Syntaxnchan_redis_idle_channel_cache_timeout time;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The nchan_redis_idle_channel_cache_timeout directive specifies the duration for which idle pub/sub channels are retained in a Redis cache. This setting is essential in scenarios where multiple subscribers or publishers connect to a channel intermittently. By retaining idle channels for a specified timeout period, it minimizes the overhead of creating and destroying channels frequently. If a channel remains inactive for longer than the configured timeout, it is eligible for eviction from the cache, thus freeing up Redis memory resources and maintaining optimum performance.

This directive should be configured in contexts like http, server, or location, allowing for flexibility depending on whether you want the timeout to apply globally, to a specific server block, or to a particular location. The argument for this directive must be provided as a time value (e.g., 60s, 5m), indicating how long an idle channel should remain in the cache. Upon reaching this duration without any activity, the channel will be removed from the Redis store, enabling the system to adaptively manage its resource usage based on current demand.

In practice, the nchan_redis_idle_channel_cache_timeout directive can help improve the effectiveness of system resources while ensuring that users experience minimal disruptions when they return to previously active channels. Correctly configuring this timeout is crucial for balancing resource retention and availability of channels for active subscribers.

Config Example

nchan_redis_idle_channel_cache_timeout 1m;

Ensure the timeout value is not set excessively low, as this may lead to frequent channel evictions and increased channel re-creation overhead.

Properly adjust the timeout based on your application's subscription activity patterns to avoid losing necessary channels too soon.

← Back to all directives