nchan_group_max_messages_memory

The `nchan_group_max_messages_memory` directive sets a limit on the maximum number of messages that can be stored in memory for a specific pub/sub channel group.

Syntaxnchan_group_max_messages_memory size;
Defaultnone
Contextlocation
Arguments1

Description

The nchan_group_max_messages_memory directive is a configuration setting used in the Nchan module for NGINX, focusing on controlling resource allocation for a pub/sub channel group. By defining this directive, users can specify the maximum amount of memory (in bytes) allocated to store messages for a channel group. This is particularly beneficial in applications where numerous messages are being published and need to be managed efficiently to prevent excessive memory usage that could lead to server performance degradation or failures due to resource exhaustion.

When the memory limit set by this directive is reached, older messages will be discarded to make space for new incoming messages. This ensures that the message buffer remains within the bounds defined by the administrator, thus providing a level of control and predictability over memory consumption. The nchan_group_max_messages_memory directive can be set to any non-negative integer, indicating the desired byte limit. If set to 0, it implies that no memory limit is applied, which is not generally recommended for production environments as it can lead to resource exhaustion.

It's important to note that this directive should typically be used in conjunction with other configuration directives related to message storage, such as nchan_channel_id, to ensure comprehensive control over message delivery and storage across multiple channels. Proper tuning of these settings will allow for optimal performance in high-load scenarios commonly seen in modern web applications, especially those relying heavily on real-time communication such as chat applications or live updates.

Config Example

location /pubsub {
    nchan_pubsub;
    nchan_group_max_messages_memory 10m;
}

Setting the value too low may lead to message loss during high throughput.

If nchan_group_max_messages_memory exceeds server capacity, it can lead to inability to process new messages.

Remember that memory limits are about the total memory used across all messages in the group; proper testing should ensure stability.

← Back to all directives