push_stream_max_messages_stored_per_channel
Specifies the maximum number of messages stored for each push stream channel.
Description
The push_stream_max_messages_stored_per_channel directive allows administrators to specify a defined limit on the number of messages retained on a channel in the NGINX Push Stream Module. This limit is important for managing memory usage and ensuring that channel data does not grow unchecked. By configuring this directive, the server automatically enforces the maximum message limit, retaining only the latest messages once the specified threshold is reached. When new messages are added beyond this limit, the oldest messages are discarded to maintain the defined cap.
This directive can be set in the http context and requires a single integer argument, which indicates the maximum messages that can be stored per channel. A prudent setting for this value will depend on the application's requirements and the expected usage patterns for the channels. For instance, if an application is expected to have highly dynamic message flow where only the recent messages are relevant, a lower threshold may be appropriate. Conversely, for applications that require retaining more historical context, a larger number may be set.
Keep in mind that setting this value too high can lead to increased memory consumption, impacting server performance, while setting it too low may lead to loss of important information as messages are removed once the limit is reached.
Config Example
http {
push_stream_max_messages_stored_per_channel 100;
}Remember that setting a low limit can lead to important messages being discarded quickly.
If this directive is not set, channels may accumulate an unlimited number of messages, potentially leading to high memory usage.