nchan_permessage_deflate_compression_memlevel

This directive sets the memory level parameter for per-message deflate compression in Nchan WebSocket communications.

Syntaxnchan_permessage_deflate_compression_memlevel number;
Default6
Contexthttp
Arguments1

Description

The nchan_permessage_deflate_compression_memlevel directive is used to configure the memory utilization level for the per-message deflate compression in Nchan, which serves as an efficient pub/sub server for web applications. It determines how much memory should be allocated for compression during WebSocket communication. The parameter can range from 1 to 9, with lower values indicating less memory usage but potentially lower compression ratios, while higher values allow for better compression at the expense of increased memory usage. This is particularly useful when scaling communication over WebSocket connections while managing the balance between performance and resource utilization.

Setting nchan_permessage_deflate_compression_memlevel can significantly impact both the throughput of messages sent over WebSocket channels and the server's memory footprint. A value of 1 uses minimal memory and offers the fastest compression speeds, while a value of 9 maximizes compression performance, making it ideal for bandwidth-sensitive applications. When the directive is configured, Nchan will automatically compress outgoing messages using the specified memory level, enhancing efficiency in high-load scenarios where message sizes vary considerably. Users must also take into account that if memory limits are exceeded, the server could potentially slow down or throttle connections as it reallocates resources.

It's crucial to properly test and monitor the performance of your configuration to find the optimal settings that suit your particular workload and server capabilities. Adjusting this directive can be a key factor in optimizing overall application performance, especially in environments with multiple simultaneous WebSocket connections.

Config Example

http {
    nchan_permessage_deflate_compression_memlevel 7;
    # other Nchan configurations...
}

Setting the memory level too low may result in insufficient compression for larger messages.

Setting the memory level too high might increase memory usage significantly, potentially affecting server performance under heavy load.

← Back to all directives