Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| cdn [2025/01/31 01:45] – ischluff | cdn [2025/11/03 12:23] (current) – ischluff | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| < | < | ||
| - | This documentation describes our Livestreaming CDN as of 2024. | + | This documentation describes our Livestreaming CDN as of 2025. |
| The File-CDN for media.ccc.de is described on [[software: | The File-CDN for media.ccc.de is described on [[software: | ||
| Line 13: | Line 13: | ||
| == Architecture | == Architecture | ||
| - | The CDN-Cascade has 5 stages: | + | The CDN-Cascade has 6 stages: Encoder, Ingest, Transcoder, |
| + | {{: | ||
| - | {{: | + | === 1. Encoder |
| - | + | The initial | |
| - | === 1. Master-Encoder | + | The encoding |
| - | The master | + | |
| - | The master | + | |
| The translated audio tracks and the slide video track are optional. | The translated audio tracks and the slide video track are optional. | ||
| - | The master | + | The origin |
| === 2. Ingest | === 2. Ingest | ||
| - | The ingest machines run both [[https:// | + | The ingest machines run both [[https:// |
| Additionally the ingest machines run a stream-api daemon which scrapes the local stream information from both srtrelay and nginx-rtmp and publishes it to consul KV. | Additionally the ingest machines run a stream-api daemon which scrapes the local stream information from both srtrelay and nginx-rtmp and publishes it to consul KV. | ||
| Line 43: | Line 42: | ||
| # consul kv get / | # consul kv get / | ||
| myloc-transcoder3 | myloc-transcoder3 | ||
| + | |||
| + | # To reallocate a transcoder for a stuck stream | ||
| + | consul kv delete / | ||
| ``` | ``` | ||
| Line 48: | Line 50: | ||
| The transcode updates are also published to the #voc-wok IRC. | The transcode updates are also published to the #voc-wok IRC. | ||
| - | The transcoding outputs are directly pushed with HTTP uploads to the Master relay. To ensure proper retries the uploads are sent over a local http-proxy (https:// | + | The transcoding outputs are directly pushed with HTTP uploads to the Origin relays. To ensure proper retries the uploads are sent over a local http-proxy (https:// |
| - | === 4. Master Relay | + | === 4. Origin Relays |
| - | Runs the upload server (https:// | + | Origin relays run the upload server (https:// |
| The upload server has some additional logic to rewrite the HLS playlists on the fly in order to properly handle stream restarts. | The upload server has some additional logic to rewrite the HLS playlists on the fly in order to properly handle stream restarts. | ||
| - | The segmented streams, thumbnails etc. are served by nginx. | + | The segmented streams, thumbnails etc. are currently |
| === 5. Edge-Relays | === 5. Edge-Relays | ||
| - | The edge relays run nginx with caching proxy config and upstream set to the master | + | The edge relays run nginx with caching proxy config and upstream set to the active origin |
| - | == Stream-URLs | + | === 6. Loadbalancer |
| + | The end-user facing domains '' | ||
| - | The resulting stream URLs are as follows: | + | ==== streaming.media.ccc.de |
| + | The load-balancers serve the [[:software: | ||
| - | MPEG-DASH (VPx Multi-Quality + Multi-Lang) | + | ==== cdn.c3voc.de |
| - | * http://cdn.c3voc.de/ | + | Requests to '' |
| - | HLS (h.264 Multi-Quality + Multi-Lang) | + | The relay weight distribution is stored in consul KV and can be tweaked in real time. The haproxy configs automatically get updated by consul-template after a change. |
| - | * http:// | + | |
| - | Moar HLS | + | ``` |
| - | * http:// | + | # Get the current weight distribution, if not explicitly set the default is 100 |
| - | * http://cdn.c3voc.de/hls/sX/ | + | consul kv get -recurse |
| - | * http://cdn.c3voc.de/hls/ | + | services/haproxy/backends/live.event.c3voc.de/weight:1 |
| - | * http://cdn.c3voc.de/hls/sX/translated_sd.m3u8 | + | services/haproxy/backends/relive.c3voc.de/weight:1 |
| - | * http://cdn.c3voc.de/hls/ | + | ``` |
| - | Audio-MP3: | + | Because of the behavior of HLS/DASH clients if a client fetches a playlist file and gets a redirect, all further requests go to the same origin. With this trick the clients stay persistently on one relay until they are redirected. |
| - | * http://cdn.c3voc.de/ | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | Audio-Opus: | + | == Stream-URLs |
| - | * http:// | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | == Loadbalancer | + | The resulting stream URLs are as follows (replace @slug with your actual stream slug): |
| - | The end-user facing domains '' | + | |
| - | === streaming.media.ccc.de | + | HLS (H.264 multi-quality + multi-language) |
| - | Unter dieser Domain liefern beide LBs unabhängig von einander die [[:software: | + | * http://cdn.c3voc.de/ |
| - | === cdn.c3voc.de | + | Moar HLS |
| - | Requests to '' | + | * http://cdn.c3voc.de/ |
| + | * http://cdn.c3voc.de/ | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * http:// | ||
| - | Because of the behavior of HLS/DASH clients if a client fetches a playlist file and gets a redirect, all further requests go to the same origin. With this trick the clients stay persistently on one relay until they are redirected. | + | **Currently not active:** |
| - | === Dynamic RTMP endpoints with RTMP Auth | + | MPEG-DASH (VPx multi-quality + multi-language) |
| - | RTMP Endpoints can be created under https://ingest.c3voc.de/backend/ (Password in keepass under ansible/stream-api/ | + | * http://cdn.c3voc.de/dash/@slug/manifest.mpd |
| - | Die RTMP-Url für den endpunkt '' | + | Audio-MP3: |
| + | * http://cdn.c3voc.de/ | ||
| + | * http:// | ||
| + | * http:// | ||
| + | |||
| + | Audio-Opus: | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * http:// | ||
| + | == Dynamic SRT/RTMP endpoints with RTMP Auth | ||
| + | SRT and RTMP Endpoints can be created under https:// | ||
| - | == The Future of Streaming | + | The RTMP-URL for the endpoint '' |
| - | For redundancy and ease of use the CDN is managed by a distributed system built on consul. | + | The SRT-URL would be : '' |
| - | Damit ist es möglich redundante CDN-Master sowie redundante Ingest-Server zu betreiben und trotzdem ein Web-Backend mit allen relevanten Streaming-Infos bereitzustellen. Weiterhin könnte die Streaming-Webseite intelligent auf das Vorhandensein/ | + | == Future improvements |
| - | Ein weiterer Vorteil des angedachten Setups sind deutlich geringere Latenz durch den fehlenden Fanout, sowie deutlich schnellere Stream-Restarts durch aktive Benachrichtigung der Transcoder. | + | The diagram below shows the envisioned architecture as of 2020. In the meantime many of the improvements have been integrated into the CDN. |
| + | Some more potential improvements are as follows: | ||
| + | * Dynamically adapting the streaming-website to the existence/ | ||
| + | * Building a live status dashboard which shows the current stream-> | ||
| + | * To gracefully shutdown a relay it could be instructed via consul KV to redirect all clients back to a load balancer while taking it out of the haproxy redirects. That way all clients would be redistributed to different relays. | ||
| + | * Build origin relay redundancy using dynamic upload client and relay upstream configuration. (Relay upstreams need to be sticky, because the HLS playlists generated on the origin relay are not deterministic) | ||
| + | * Use DNS rotation on ingest | ||
| + | * Finalize srtrelay meshing to allow pushed streams to be pulled from any ingest machine. | ||
| - | === Übersicht | ||
| {{drawio> | {{drawio> | ||