Lesson 9 of 16
26. CDNs

26.8 How do CDNs deliver video (HLS, DASH)?

3 min read+10 XP

In the warehouse: A two-hour film isn't shipped as one giant crate. It's cut into short reels, each packed in several qualities. The cinema picks which quality of each reel to show depending on how good its projector is that minute.

In the system: Streaming video over a CDN works by turning one big video into many small files:

  • The video is encoded into a ladder of qualities (for example 240p at 400 kbps up to 1080p at 5 Mbps).
  • Each quality is cut into segments of a few seconds. Apple's HLS authoring guidance targets 6-second segments.
  • Playlists list the segments: HLS uses .m3u8 files (a master playlist pointing to one playlist per quality); MPEG-DASH uses an .mpd manifest.
  • The player downloads the playlist, then segments one by one, choosing the quality for each segment from its measured bandwidth (adaptive bitrate, ABR).

a master playlist lists qualities; the player picks a quality for each 6-second segment.

Figure: every segment is an ordinary file the CDN can cache; the player switches quality as the network changes.

For the bookstore's 20-minute author interview: 1,200 ÷ 6 = 200 segments per quality, and with 5 qualities, 1,000 small files. A reader measuring 4 Mbps, with a 20% safety margin, gets a 3.2 Mbps budget and plays 720p (2.8 Mbps); in a tunnel, the player drops to 240p for a few segments rather than stopping.

Why this suits CDNs:

  • Segments are plain HTTP files with their own URLs, cacheable like covers; popular videos stay hot at the edge.
  • Segments never change once written, so they can be cached for a long time; for live streams, only the playlist changes every few seconds and gets a short TTL.
  • Chapters 40 and 41 design full video-on-demand and live streaming systems on top of this.

Memory code: "Cut the film into reels, in several qualities, and let the player pick reel by reel."