mp4_max_buffer_size
Sets the maximum buffer size for MP4 file streaming in NGINX. — NGINX HTTP Core
Описание
The `mp4_max_buffer_size` directive specifies the maximum size (in bytes) that NGINX will use for buffering MP4 file downloads when serving video content. This is particularly important when serving large MP4 files to ensure efficient caching and streaming performance. Setting an appropriate buffer size allows NGINX to maintain smooth playback experiences for end-users by controlling the amount of buffered data when streaming files. The directive can be set in the `http`, `server`, or `location` contexts, allowing for flexibility in configuration depending on the application's needs. If the specified buffer size is too small, it may result in frequent buffering during playback, impacting user experience. Conversely, setting it too large can lead to high memory consumption, especially when handling multiple concurrent streams. The value for this directive must be specified in bytes, and it follows the syntax `mp4_max_buffer_size size;` where size can be a simple integer for bytes or suffixed with 'k', 'm' for kilobytes or megabytes respectively. It’s essential to test the impact of different sizes based on your server capacity and expected traffic.
Пример конфига
http {
mp4_max_buffer_size 1m;
}
server {
location /videos {
mp4_max_buffer_size 2m;
}
}Using a size too small may cause video playback to buffer frequently.
Setting a size too large can consume more memory, affecting overall server performance.
Remember to test different settings under expected load scenarios to find the optimal size.