push_message_timeout
The `push_message_timeout` directive configures the maximum duration a message can be retained for a subscriber before timing out.
Description
The push_message_timeout directive is a key configuration option within the Nchan module that dictates how long a published message will be held before it is considered expired and no longer available for subscribers. This timeout is critical in situations where the subscriber may be experiencing delays in connecting or for scenarios involving high-frequency message publishing where managing message retention is necessary to optimize resources. Setting this value helps balance between providing timely updates to subscribers and resource management on the server.
This directive can be defined in various contexts including http, server, and location, making it versatile for different deployment strategies. The value provided to the directive is expected to be a time duration, which can be specified in different units such as seconds, minutes, or hours. If a subscriber is unable to consume a message before the timeout elapses, the message is discarded, reinforcing the concept of ephemeral message delivery in a pub/sub model. Careful consideration should be given to the timeout duration based on your application’s expected latency and responsiveness to ensure that subscribers have the opportunity to consume messages in a timely manner without unnecessary data accumulation.
Overall, the push_message_timeout directive serves as an essential tuning parameter in a pub/sub architecture, enabling administrators to fine-tune message expiry behavior to better meet subscriber needs while maintaining efficient server performance.
Config Example
http {
nchan_pubsub;
push_message_timeout 30s;
}Setting a timeout too low may cause subscribers to miss messages if they take longer to connect or process them.
If this directive is not set correctly, it can lead to either excessive memory use or unnecessary message loss.