nchan_group_max_messages
The `nchan_group_max_messages` directive limits the maximum number of messages retained in a channel group within Nchan.
Description
The nchan_group_max_messages directive is used to specify the maximum number of messages that can be stored in a group of channels. This setting is vital for managing resource usage and ensuring that Nchan operates efficiently, especially in high-load scenarios where multiple messages may be published rapidly. When the number of messages in the group exceeds the defined limit, Nchan will drop the oldest messages to maintain the specified count, ensuring that only the most recent messages are available to subscribers.
The directive takes an integer argument that denotes the maximum number of messages allowed in the channel group. By judiciously configuring this limit, a developer can control the trade-off between memory usage and message availability, allowing for high-throughput applications without overwhelming server resources. The context in which this directive is valid is within a location block, indicating that its settings apply specifically to channels defined within that scope.
It's important to remember that message retention settings like this can impact the delivery guarantees associated with message broadcasting. If the number of messages is consistently high, it may be prudent to monitor the configuration to ensure that critical messages are not inadvertently discarded as new messages are published.
Config Example
location /my_channel {
nchan_group_max_messages 100;
nchan_pubsub;
}If not set, the group may consume more memory than desired, potentially leading to server performance issues.
An insufficient limit may cause important messages to be discarded if they exceed the configured maximum.
This directive must be placed within a location block to take effect.