nchan_group_max_messages_disk

The `nchan_group_max_messages_disk` directive limits the number of messages that can be stored on disk for a channel group.

Syntaxnchan_group_max_messages_disk number;
Defaultnone
Contextlocation
Arguments1

Description

The nchan_group_max_messages_disk directive is used within the context of the Nchan module to specify the maximum number of messages that can be stored on disk for a specific pub/sub channel group. When a channel group exceeds the specified limit, it starts dropping the oldest messages to make room for new ones. This behavior ensures that the storage requirements of the application do not grow indefinitely, preserving disk usage and managing resource allocation efficiently. The directive impacts how messages are retained for subscribers when persistent storage (on-disk storage) is utilized, providing an essential feature for applications that rely on both transient and persistent message delivery.

This directive takes a single argument, which must be a non-negative integer representing the maximum number of messages allowed. It can be set on a per-location basis in the Nginx configuration, thus enabling different channels or groups to have unique storage limits based on their usage patterns. Setting this directive correctly is crucial, especially for high-volume channels, as not doing so can result in message loss if the system does not have sufficient storage to retain messages for subscribers that connect later.

Moreover, because messages might be dropped when the limit is reached, proper attention should be given to how this directive interacts with message publishing and subscription patterns. For instance, if subscribers expect to receive all messages, they may need to be aware of this limit to avoid missing critical information. The retention policy can affect the comprehensiveness of the data received by end-users, resulting in possible data integrity issues if not managed properly.

Config Example

location /pubsub {
    nchan_pubsub;
    nchan_group_max_messages_disk 1000;
}

Setting a value lower than the number of existing disk messages may lead to immediate message loss.

Ensure that the limit aligns with the application's expectations for message retention.

Monitor disk usage if many groups are configured with high limits to prevent storage exhaustion.

← Back to all directives