nchan_use_redis

The `nchan_use_redis` directive enables the use of Redis as a storage backend for message buffering in the Nchan module.

Syntaxnchan_use_redis on | off;
Defaultoff
Contexthttp, server, location
Arguments1

Description

The nchan_use_redis directive is crucial for integrating Nchan with Redis, allowing message storage and retrieval to be handled by a Redis instance. When set, this directive connects your Nchan setup to a Redis server, enabling scalable message buffering that can persist messages beyond the lifespan of an Nginx worker process. This is particularly beneficial for applications with numerous subscribers requiring consistent message delivery. By configuring Nchan to use Redis, you can manage message dispatching dynamically across distributed Nginx servers, facilitating robust, high-availability pub/sub implementations.

The directive takes one argument, which specifies the Redis server's connection string. This string can include details such as the hostname, port, and any necessary authentication parameters. Depending on the deployment, it can be set in various contexts like http, server, or location, providing flexibility in configuration. Additionally, using Redis allows for geo-redundancy and load balancing, as multiple Nginx instances can simultaneously access the same Redis backend, promoting high availability and reliability in message passing.

Config Example

http {
    nchan_use_redis on;

    server {
        location /pub {
            nchan_pubsub;
        }
        location /sub {
            nchan_subscriber;
        }
    }
}

Ensure that Redis is properly installed and accessible from the Nginx server.

Incorrect connection strings may lead to failure in message buffering and delivery.

Using Redis incurs additional latency compared to in-memory storage, which may affect performance.

← Back to all directives