nchan_max_reserved_memory

Sets the maximum amount of memory that Nchan will allocate for reserved buffers during message publishing and subscribing processes.

Syntaxnchan_max_reserved_memory size;
Defaultnone
Contexthttp
Arguments1

Description

The nchan_max_reserved_memory directive configures the upper limit of memory reserved for Nchan's internal message buffering mechanism, which is crucial for efficient message management in a pub/sub scenario. When clients publish or subscribe to messages, Nchan utilizes this reserved memory to temporarily store messages until they can be processed or delivered. This directive is essential for tuning performance, especially under heavy load, as it directly influences how many messages can be queued in memory before the server starts dropping messages or hitting resource limits.

The parameter for this directive accepts a size in bytes, kilobytes (k), megabytes (m) or gigabytes (g). Setting this value too low may result in message loss during peak periods when many messages are being published-since once the limit is reached, Nchan will be unable to allocate additional memory for incoming messages. Conversely, a very high setting can lead to inefficient memory usage and potential server instability if the memory is exhausted. Therefore, it’s important to monitor your application needs closely and adjust this value based on empirical tests of traffic and memory consumption.

Config Example

http {
    nchan_max_reserved_memory 128m;
}

Setting this value too low may result in message loss under high load scenarios.

Avoid setting extremely high values as it may lead to memory exhaustion for the server.

Monitoring is essential; without it, misconfigurations can result in degraded performance.

← Back to all directives