push_max_channel_subscribers

Limits the maximum number of subscribers for a channel in Nchan pub/sub configuration.

Syntaxpush_max_channel_subscribers number;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The push_max_channel_subscribers directive in Nginx's Nchan module is designed to impose an upper limit on the number of subscribers that can connect to a specific pub/sub channel. This can help prevent resource exhaustion on your server by controlling the number of concurrent connections allowed for each channel, thus enabling better performance management and stability under high subscriber loads. When the configured limit is reached, additional subscribers will be rejected, ensuring that the server remains responsive for active users.

This directive is utilized by specifying a numerical argument that represents the maximum number of subscribers. It can be placed in different contexts such as http, server, and location, allowing flexibility in how granularly you wish to control subscriber limits across different portions of your application. When an attempt is made to add more subscribers than the specified limit, Nchan sends a response indicating that the maximum number of subscribers has been exceeded. These limitations can be crucial for scenarios where certain channels are expected to have high engagement, allowing developers to mitigate potential server overloads or performance degradation.

Proper configuration of subscriber limits can greatly enhance the scalability of applications, making Nchan a robust choice for implementing real-time features in web applications. Administrators should monitor channel usage to adjust this parameter as user engagement patterns evolve, ensuring a balance between availability and resource optimization.

Config Example

location /pubsub {
    nchan_pubsub;
    push_max_channel_subscribers 100;
}

Setting this value too low may prevent legitimate users from subscribing to busy channels.

If the server receives a lot of connection attempts, ensure that the directive is set according to expected traffic to avoid service denial.

This directive does not affect clients that are already subscribed; it only limits new connections.

← Back to all directives