Broadcast Errors // StreamRelay Lab
LL-HLS Segment 404s & Disk I/O Thrash on Slow Storage
Writing 200ms LL-HLS parts every fifth of a second onto shared HDD/SSD volumes creates fsync stalls that cause players to fetch expired segments and hit HTTP 404.
Measured MediaMTX & FFmpeg Telemetry
Low-Latency HLS writes new partial segments every 200 ms and deletes old ones after hlsSegmentCount (7). Storing ephemeral 7-second live ring segments on physical disk wastes IOPS and triggers 404s during disk flush spikes.
| Subsystem / Signal | Measured Target | Operational Impact |
|---|---|---|
| 200ms LL-HLS Write Rate | 5 partial files/sec per stream | 432,000 ephemeral file writes/day |
| Ring Memory Footprint | 180 - 480 MB total | Fits easily in /dev/shm RAM tmpfs |
| hlsSegmentCount Safe Floor | 7 segments x 1s | Gives 7s jitter window against 404s |
Step-by-Step Triage & Config Remediation
- Point hlsDirectory to /dev/shm: Set hlsDirectory: /dev/shm/mediamtx-hls so every .m4s part stays strictly in RAM.
- Keep 7x 1s segments: Set hlsSegmentCount: 7 and hlsSegmentDuration: 1s so slow mobile clients never request evicted segments.
- Disable proxy caching on .m3u8: Ensure Nginx/Caddy sets Cache-Control: no-cache on playlists while caching .m4s/.ts segments for 10s.
# mediamtx.yml zero-disk LL-HLS configuration hls: yes hlsAddress: :8888 hlsVariant: lowLatency hlsSegmentCount: 7 hlsSegmentDuration: 1s hlsPartDuration: 200ms hlsDirectory: /dev/shm/mediamtx-hls
Diagnostic FAQ
How much RAM does /dev/shm need for MediaMTX HLS?
A 7-second ring at 10 Mbps (even with 3 ABR rungs) uses under 50 MB of RAM; reserving 256-512 MB in /dev/shm is plenty.
What happens if the server reboots with /dev/shm?
Live HLS segments are ephemeral anyway; systemd ExecStartPre=mkdir -p /dev/shm/mediamtx-hls recreates the ring directory on boot.