Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cdn [2025/01/31 01:45] ischluffcdn [2025/11/03 12:23] (current) ischluff
Line 2: Line 2:
  
 <bootnote> <bootnote>
-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:voctoweb]]. The File-CDN for media.ccc.de is described on [[software:voctoweb]].
Line 13: Line 13:
  
 == Architecture == Architecture
-The CDN-Cascade has stages: Master-Encoder, Ingest, Transcoder, Master-Relays and finally Edge-Relays.+The CDN-Cascade has stages: Encoder, Ingest, Transcoder, Origin-RelaysEdge-Relays and finally Load-balancers. 
 +{{:cdn_overview.drawio.png|}}
  
-{{:cdn_overview.png?1200|}} +=== 1. Encoder 
- +The initial stream encoding is created near the stage on the encoder PC running voctomix or any video-encoder for third party streams. 
-=== 1. Master-Encoder +The encoding usually contains a 1080p25 H264 video signal, the slides as 1080p5 and up to 3 tracks of audio encoded in AAC (Native, Translated, Translated-2).
-The master stream encoding is created near the stage on the encoder PC running voctomix or on with other videoencoder for third party streams. +
-The master encoding contains a 1080p25 H264 video signal, the slides as 1080p5 and up to 3 tracks of audio encoded in AAC (Native, Translated, Translated-2).+
 The translated audio tracks and the slide video track are optional. The translated audio tracks and the slide video track are optional.
  
-The master encoding is pushed as MPEG-TS via SRT to the ingest stage.+The origin encoding is pushed as MPEG-TS via SRT to the ingest stage.
  
 === 2. Ingest === 2. Ingest
-The ingest machines run both [[https://github.com/voc/srtrelay|srtrelay]] and nginx-rtmp to receive pushed streams from the master encoders. This also serves as the entry point for third party streams.+The ingest machines run both [[https://github.com/voc/srtrelay|srtrelay]] and nginx-rtmp to receive pushed streams from the encoders. This also serves as the entry point for third party streams.
  
 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 /stream/s96/transcoder # consul kv get /stream/s96/transcoder
 myloc-transcoder3 myloc-transcoder3
 +
 +# To reallocate a transcoder for a stuck stream
 +consul kv delete /stream/s96/transcoder
 ``` ```
  
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://github.com/voc/stream-api/tree/master/cmd/upload-proxy).+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://github.com/voc/stream-api/tree/master/cmd/upload-proxy).
  
-=== 4. Master Relay +=== 4. Origin Relays 
-Runs the upload server (https://github.com/voc/stream-api/tree/master/cmd/upload-server) which receives the http uploads and stores the files on local disk.+Origin relays run the upload server (https://github.com/voc/stream-api/tree/master/cmd/upload-server) which receives the http uploads and stores the files on local disk.
 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 served by nginx.
  
 === 5. Edge-Relays === 5. Edge-Relays
-The edge relays run nginx with caching proxy config and upstream set to the master relay.+The edge relays run nginx with caching proxy config and upstream set to the active origin relay.
  
-== Stream-URLs+=== 6. Loadbalancer 
 +The end-user facing domains ''streaming.media.ccc.de'' as well as ''cdn.c3voc.de'' are served by the load-balancers using DNS round robin.
  
-The resulting stream URLs are as follows:+==== streaming.media.ccc.de 
 +The load-balancers serve the [[:software:streamingwebsite|Streaming-Webseite]] under this domain. The sites run completely independent and are just kept in sync by the deployment script. With this procedure one or more load-balancers can easily be taken out of the DNS rotation if necessary.
  
-MPEG-DASH (VPx Multi-Quality + Multi-Lang) +==== cdn.c3voc.de 
-* http://cdn.c3voc.de/dash/sX/manifest.mpd+Requests to ''cdn.c3voc.de'' are handled by haproxy on the load-balancers with redirects to one of the edge relays. The redirects are performed following a preconfigured weight distribution.
  
-HLS (h.264 Multi-Quality + Multi-Lang) +The relay weight distribution is stored in consul KV and can be tweaked in real timeThe haproxy configs automatically get updated by consul-template after a change.
-* http://cdn.c3voc.de/hls/sX/native_hd.m3u8+
  
-Moar HLS +``` 
-* http://cdn.c3voc.de/hls/sX/translated_hd.m3u8 (auch Multi-Langnur anderer Default) +# Get the current weight distributionif not explicitly set the default is 100 
-* http://cdn.c3voc.de/hls/sX/translated-2_hd.m3u8 +consul kv get -recurse /services/haproxy/backends
-* http://cdn.c3voc.de/hls/sX/native_sd.m3u8 (nur SD, aber trotzdem Multi-Lang) +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/sX/translated-2_sd.m3u8+```
  
-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 originWith this trick the clients stay persistently on one relay until they are redirected.
-* http://cdn.c3voc.de/sX_native.mp3 +
-* http://cdn.c3voc.de/sX_translated.mp3 +
-* http://cdn.c3voc.de/sX_translated-2.mp3+
  
-Audio-Opus: +== Stream-URLs
-* http://cdn.c3voc.de/sX_native.opus +
-* http://cdn.c3voc.de/sX_translated.opus +
-* http://cdn.c3voc.de/sX_translated-2.opus+
  
-== Loadbalancer +The resulting stream URLs are as follows (replace @slug with your actual stream slug):
-The end-user facing domains ''streaming.media.ccc.de'' as well as ''cdn.c3voc.de'' are served by the load balancers using DNS round robin.+
  
-=== streaming.media.ccc.de +HLS (H.264 multi-quality + multi-language) 
-Unter dieser Domain liefern beide LBs unabhängig von einander die [[:software:streamingwebsite|Streaming-Webseite]] ausDie LBs sind dabei komplett unabhängig voneinander und haben auch je eine eigene KonfigurationEs ist aufgabe des Website-Deployments die Konfiguration synchron zu halten. Durch dieses Setup kann bei Bedarf der jeweilige LB einfach aus der DNS-Rotation herausgenommen werden.+* http://cdn.c3voc.de/hls/@slug/native_hd.m3u8
  
-=== cdn.c3voc.de +Moar HLS 
-Requests to ''cdn.c3voc.de'' are handled by haproxy on the load balancers with redirects to one of the edge relaysThe redirects are according to a preconfigured weight distribution.+  * http://cdn.c3voc.de/hls/@slug/translated_hd.m3u8 - also multi-language, just a different default language 
 +  * http://cdn.c3voc.de/hls/@slug/translated-2_hd.m3u8 
 +  * http://cdn.c3voc.de/hls/@slug/native_sd.m3u8 - only SD, but still multi-language 
 +  * http://cdn.c3voc.de/hls/@slug/translated_sd.m3u8 
 +  * http://cdn.c3voc.de/hls/@slug/translated-2_sd.m3u8
  
-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/htpasswd). After creating the endpoint the stream can be pushed to any ingest machine.+* http://cdn.c3voc.de/dash/@slug/manifest.mpd
  
-Die RTMP-Url für den endpunkt ''stream/qtest23'' mit auth token lautet z.B.: ''%%rtmp://ingest.c3voc.de/stream/qtest23?auth=token%%''+Audio-MP3: 
 +* http://cdn.c3voc.de/@slug_native.mp3 
 +* http://cdn.c3voc.de/@slug_translated.mp3 
 +* http://cdn.c3voc.de/@slug_translated-2.mp3 
 + 
 +Audio-Opus: 
 +* http://cdn.c3voc.de/@slug_native.opus 
 +* http://cdn.c3voc.de/@slug_translated.opus 
 +* http://cdn.c3voc.de/@slug_translated-2.opus 
 +== Dynamic SRT/RTMP endpoints with RTMP Auth 
 +SRT and RTMP Endpoints can be created under https://ingest.c3voc.de/backend/ (Password in keepass under ansible/stream-api/htpasswd). After creating the endpoint the stream can be pushed to any ingest machine.
  
-== The Future of Streaming+The RTMP-URL for the endpoint ''stream/qtest23'' on ingest1 would be: ''%%rtmp://ingest.c3voc.de/stream/qtest23?auth=<token>%%''
  
-For redundancy and ease of use the CDN is managed by a distributed system built on consul.+The SRT-URL would be : ''%%srt://ingest.c3voc.de:1337?streamid=publish/qtest23/<token>%%''
  
-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/Fehlen von Streams im CDN reagieren und zusätzliche Metadaten von Encodern verarbeiten.+== 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/lack of a stream 
 + * Building a live status dashboard which shows the current stream->ingest->transcoder pipelines 
 + * 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>diagram1.png}} {{drawio>diagram1.png}}
  
  
  
  • cdn.1738284330.txt.gz
  • Last modified: 2025/01/31 01:45
  • by ischluff