← Back to System Design, page 4

system-design-0067 · Medium mid

Design a Netflix-style video-on-demand service that streams a fixed catalogue to 30 million concurrent viewers at peak, using a CDN that is filled before demand arrives.

Encode every title once into many bitrate and device variants, store them in object storage, and copy them in advance to CDN appliances inside internet providers' networks during quiet hours, based on predicted popularity. The control plane (sign-in, catalogue, recommendations, choosing a CDN server) runs in the cloud; the data plane (video bytes) comes almost entirely from nearby caches. Peak egress is about 150 Tbps for 30 million viewers at 5 Mbps.

Full answer

Requirements

Functional:

  • Browse the catalogue, play a title, resume where you stopped, on TVs, phones and browsers.
  • Adaptive quality, subtitles and multiple audio tracks; downloads for offline viewing.

Non-functional:

  • Playback starts in about 2 seconds and rarely rebuffers.
  • Peak evening traffic is served without overloading transit links.
  • Content is protected with DRM.

Capacity estimates

Assumptions: 30M concurrent viewers at peak, 5 Mbps average, 5,000 titles averaging 1.5 hours, 10 renditions per title, 2 GB per hour per rendition on average.

  • Peak egress: 30M x 5 Mbps = 150 Tbps.
  • Catalogue size: 5,000 x 1.5 x 10 x 2 GB = 150 TB. Small enough that a large CDN site can hold the whole popular part of it.
  • This is why pre-positioning works: the catalogue is fixed and known, unlike user-generated video.

API

GET /v1/catalog/rows?profile=.. -> personalised rows of titles POST /v1/playback/{title_id}/start -> {"manifest_url": "https://cdn-node-17.isp.example/...", "license_url": "...", "resume_s": 1830} POST /v1/playback/{session}/heartbeat {"position_s": 1890, "bitrate": 4300}

The manifest lists renditions and the specific nearby CDN servers that hold the files.

Data model

  • titles: title_id, metadata, artwork, available regions.
  • assets: title_id, rendition (codec, resolution, bitrate), object key, checksum.
  • viewing_progress: (profile_id, title_id) to position and updated_at, in a key-value store.
  • cdn_inventory: which appliance holds which assets, and its health and load.

High-level design

mermaid
flowchart LR
  ST[Studio masters] --> ENC[Encoding pipeline]
  ENC --> OS[(Object storage)]
  OS -- "nightly fill" --> APP[CDN appliances inside ISPs]
  D[Device] --> CP[Control plane in cloud]
  CP --> STEER[Steering service]
  STEER --> APP
  D -- "video bytes" --> APP
  D --> LIC[DRM license service]

Key techniques

  • Per-title and per-scene encoding. Simple cartoons need fewer bits than action films; choosing bitrates per title saves bandwidth at the same quality.
  • Pre-positioning. Each night, a popularity forecast decides which files each appliance should hold. New releases are pushed before launch day.
  • Steering. At play time, the control plane picks appliances close to the viewer that hold the files and are healthy, and lists a few fallbacks.
  • Client logic. The player picks bitrates from measured throughput and buffer level, and switches server if one is slow.

Bottlenecks and trade-offs

  • Forecast misses. A surprise hit may not be on local appliances; fall back to regional caches and fill on demand.
  • Storage versus egress. More renditions improve quality on every device but multiply storage and fill traffic.
  • Control plane outage stops new plays even if caches are healthy; run it in several regions and cache catalogue responses on devices.
  • Own CDN versus commercial CDN. Placing appliances in ISPs cuts transit cost and latency at huge scale, but needs partnerships and operations work; smaller services should rent a commercial CDN.
  • DRM licence requests are on the start-up path; keep them fast and regional.

By level

Fresher: Explain that videos are copied to servers near viewers before people watch them, and that the app picks a quality based on the internet speed. A fresher should describe resume playback.

Mid: Size egress and storage, design pre-positioning and steering, and explain per-title encoding. Mention DRM on the start path.

Senior: Discuss forecast misses, own versus rented CDN, control plane resilience, quality measurement and encoding economics. Expect reasoning that ties catalogue size to the caching strategy.

Key points

  • Encode once into many renditions
  • Pre-position files in ISP caches during quiet hours
  • Control plane in the cloud, data plane at the edge
  • About 150 Tbps at peak for 30 million viewers
  • Steering picks healthy nearby caches with fallbacks

Common mistakes

  • Serving video bytes from cloud servers
  • Treating a fixed catalogue like user uploads
  • One bitrate ladder for every title
  • Forgetting that the control plane is still needed to start playback

Follow-ups

  • How would you handle a surprise hit show?
  • How do downloads for offline viewing work with DRM?
  • How would you measure playback quality across devices?

Tips

  • Contrast with live streaming and user-generated video
  • Do the egress and catalogue math
  • Explain control plane versus data plane

Evaluation rubric

  • Clear separation of control and data planes
  • Correct capacity math
  • Pre-positioning and steering
  • Trade-offs on renditions, CDN ownership and failures