nchan_redis_ping_interval

The `nchan_redis_ping_interval` directive sets the interval at which Nchan pings the Redis server to maintain a connection.

Syntaxnchan_redis_ping_interval seconds;
Defaultnone
Contexthttp, server, location, upstream
Arguments1

Description

The nchan_redis_ping_interval directive is used within the Nchan module for NGINX to specify how often Nchan should send a ping command to a Redis server to keep the connection alive. This is particularly important in environments where Redis connections can become inactive due to idleness or network issues. When using Redis as a backend for message storage and pub/sub functionalities, maintaining an active connection ensures that messages can be published and subscribed without interruptions.

The value provided for this directive is specified in seconds and determines the frequency of these pings. Ideally, this interval should be set to a value that balances between minimizing network load and ensuring that the connection does not get closed due to inactivity. This directive can be placed in various contexts including http, server, location, or upstream, making it flexible for different configurations of Nchan within an NGINX setup. Proper tuning of this value can help to avoid connection timeouts and enhance the reliability of interactions with the Redis server.

Additionally, if you are using Redis clusters or have specific Redis connection settings, consider how the ping interval may affect your overall architecture. Connection settings in Redis such as tcp-keepalive may also interact with the nchan_redis_ping_interval, so it's important to test and understand the integrated behavior of these settings in a production environment.

Config Example

http {
    nchan_redis_ping_interval 30;
}

Setting the ping interval too low can increase network traffic unnecessarily.

If using Redis in a cloud environment, ensure that your security groups and firewalls allow the ping traffic.

A very high ping interval might lead to connection drops, especially in unreliable networks.

← Back to all directives