push_stream_channel_inactivity_time
Sets the inactivity timeout for push stream channels, allowing for automatic cleanup of inactive channels.
Description
The push_stream_channel_inactivity_time directive defines the time period after which an inactive channel is considered stale and can be automatically deleted. This is particularly useful in scenarios where channels may become unneeded due to inactivity, freeing up resources and ensuring that memory is efficiently managed. The directive takes a single argument, which specifies the time period in seconds. If a channel does not receive any subscriptions or activity within this defined timeframe, it will be removed from the server's active channels, preventing unnecessary memory use and keeping the system clean.
For example, if you set push_stream_channel_inactivity_time 10;, any channel that does not receive any activity within 10 seconds will be automatically deleted. This feature is useful for applications where users may subscribe to channels intermittently, minimizing server load by ensuring channels are only kept active when needed. It's important to consider the user experience when setting this value; too short of an inactivity time may lead to users being unexpectedly disconnected from channels they wish to access, while too long may lead to resource exhaustion due to many stale channels remaining in memory.
Config Example
http {
push_stream_channel_inactivity_time 300;
server {
location /pub {
push_stream_publisher;
push_stream_channels_path $arg_id;
}
location ~ /sub/(.*) {
push_stream_subscriber;
push_stream_channels_path $1;
}
}
}Ensure the inactivity time is appropriately set to avoid unintentional loss of channels that users may still want to access.
If the value is set to too low, users may experience disconnections if they are inactive for that duration.
Configuration must be placed in the correct context (http) to be effective.