push_store_messages
The `push_store_messages` directive configures the storage behavior for messages published to channels in the Nchan module.
Description
The push_store_messages directive in Nchan controls how messages are stored after being published to a channel. Depending on the configuration, it can either store messages in memory or in a more persistent storage mechanism, like Redis. This directive plays a crucial role in determining the durability of messages that are sent to subscribers; if a message is stored, it remains available to clients connecting later, allowing for message delivery guarantees even in scenarios of network disruptions.
When defined, this directive takes a single argument that specifies the storage mode: whether to store messages or not. If enabled, this will allow the Nchan server to queue messages until they can be consumed by a subscriber, facilitating easier handling of bursts of traffic. The maximum number of messages to store is also configurable, providing flexibility based on the application’s needs. Therefore, for applications requiring resilience and high availability, configuring message storage becomes a fundamental requirement.
Using push_store_messages effectively may involve a careful balance between memory usage and the demand for message durability across different clients. Developers should consider their specific use case, such as the expected volume of messages and number of concurrent subscribers, to optimize their Nchan configuration accordingly.
Config Example
location /pubsub {
nchan_pubsub;
push_store_messages on;
}Enabling message storage can consume significant memory or disk space, depending on traffic and configuration.
If using push_store_messages with Redis, ensure Redis is properly configured and reachable from your NGINX server.