push_stream_shared_memory_size

Configures the size of shared memory allocated for the Push Stream module in NGINX.

Syntaxpush_stream_shared_memory_size size | size [optional second argument];
Defaultnone
Contexthttp
Arguments1-2

Description

The 'push_stream_shared_memory_size' directive specifies the amount of shared memory to allocate for the NGINX Push Stream module. This shared memory is utilized to maintain state and information related to channels and subscribers, which are essential for efficient message broadcasting. When setting this directive, you can designate a limit ranging from 1 byte to several gigabytes, depending on your application's scale and needs. The size defined here directly influences the number of channels and subscribers that can be effectively managed by the server, impacting overall performance and reliability of push notifications.

This directive accepts one or two arguments: the primary argument is the memory size, while an optional second argument can be used for additional configurations depending on the implementation. If the specified size is insufficient, it could lead to performance issues, such as restrictions on the number of simultaneous connections or dropped messages. Conversely, allocating an excessively large size may lead to wasted resources, so it’s essential to tailor this value to your specific usage patterns and anticipated load.

It’s worth noting that this directive must be placed within the 'http' context of your NGINX configuration. Proper configuration allows the push stream module to function optimally, guaranteeing that your live streaming or real-time data scenarios run smoothly and efficiently, adhering to both expected traffic and resource constraints.

Config Example

http {
    push_stream_shared_memory_size 32M;

    server {
        location /channels-stats {
            push_stream_channels_statistics;
            push_stream_channels_path $arg_id;
        }

        location /pub {
            push_stream_publisher admin;
            push_stream_channels_path $arg_id;
        }

        location ~ /sub/(.*) {
            push_stream_subscriber;
            push_stream_channels_path $1;
        }
    }
}

Ensure that the specified size is appropriate for the expected number of channels and subscribers to avoid performance degradation.

If the memory size is set too low, it may result in dropped messages or inability to accommodate all subscribers.

This directive is context-sensitive and should be placed in the 'http' block; failure to do so will lead to configuration errors.

← Back to all directives