relay_buffer

The relay_buffer directive specifies the buffer size for streamed video data in the NGINX RTMP module.

Syntaxrelay_buffer size;
Default1048576
Context
Arguments1

Description

The relay_buffer directive is a configuration setting in the NGINX RTMP module that determines the size of the buffer used for handling video stream data during relay or publishing operations. A properly sized buffer is crucial for optimizing video streaming performance, especially in environments with varying network conditions. By adjusting the relay_buffer value, administrators can manage how much data is temporarily stored before being sent to connected clients, which can help in accommodating bursts of data or ensuring smoother playback experiences.

The directive takes a single integer value that specifies the buffer size in bytes. When the buffer is too small, it may lead to dropped frames or interruptions in the video stream, especially during high traffic or high bitrate scenarios. Conversely, a buffer that is too large might consume unnecessary memory resources, affecting server performance and scalability. The ideal setting for relay_buffer depends on the server capabilities and the expected usage patterns of the streaming service, thus it might require some experimentation to find the optimal value for specific applications.

To implement the relay_buffer directive, it should be included in the server or application block where streaming configurations are defined. It plays a significant role in ensuring data integrity and consistency during streaming, thereby enhancing the user experience. It is also important to monitor performance and make adjustments as needed, especially in production environments where user load can vary greatly.

Config Example

rtmp {
    server {
        listen 1935;
        application live {
            live on;
            relay_buffer 2097152; # Set relay buffer size to 2MB
        }
    }
}

Misconfiguring the buffer size can lead to video stream issues, such as lag or stuttering.

Using a buffer size that is too large can waste memory resources, causing performance degradation in high-load scenarios.

Always test streaming under conditions that mimic production load to determine the appropriate buffer size.

← Back to all directives