{}DSA Atlas

Design a Video Streaming Platform (YouTube / Netflix)

Upload, process and stream video to hundreds of millions of viewers — resumable uploads, the transcoding pipeline as a DAG of parallel chunk jobs, codecs and bitrate ladders, HLS/DASH adaptive bitrate streaming, CDN strategy (including Netflix Open Connect), metadata and view counts, live streaming differences, and cost control.

Advanced5 interview questions

1. Requirements

Functional

  • Upload videos (up to several GB); process into streamable formats.
  • Watch videos on any device/network with adaptive quality; seek; resume.
  • Metadata: title, description, thumbnails; search and recommendations (out of scope beyond a mention); likes, comments, view counts.

Non-functional

  • 500M DAU; 1B hours watched/day.
  • Fast startup (< 2 s), minimal rebuffering.
  • Highly available playback; uploads can take minutes to process.
  • Cost efficient: bandwidth and storage dominate cost.

2. Estimation

QuantityValue
Uploads500 hours/minute ≈ 720k hours/day
Storage per hour (all renditions + codecs)~3–5 GB → ~3 PB/day new (+replication)
Watch bandwidth1B h/day ÷ 24 h ≈ 42M concurrent streams × ~2.5 Mbps ≈ ~100 Tbps average egress (~1 EB/day)
Metadata reads~100k–500k QPS

Conclusion: egress bandwidth and storage dwarf everything else → CDNs, efficient codecs, and tiered storage decide the design.

3. High-level design

upload & processing creator upload svcpre-signed URLs raw storage(S3) workflow engine(DAG) transcode fleet(GPU/CPU, spot) segments +manifests (S3) metadata DBstatus: ready playback viewer playback APIauth · steering edge cache(in ISP) regionalmid-tier origin(segments S3) events → Kafkaviews, QoE manifest segments
Processing is an offline DAG; playback is HTTP segment fetching from caches close to the viewer.

4. Deep dives

Upload

Resumable multipart uploads (chunks retried independently), checksum per chunk, direct to object storage via pre-signed URLs; the metadata row is created first with status = uploading.

Transcoding DAG

probe split atGOPs chunk 1 × 6 renditions chunk 2 × 6 renditions chunk … × 6 audio · thumbnails packageHLS / DASH moderation / CID publish: ready
Chunk-level parallelism turns a 2-hour transcode into minutes.
RenditionResolutionBitrate (H.264, approx.)
240p426×2400.3–0.7 Mbps
480p854×4801–2 Mbps
720p1280×7202.5–4 Mbps
1080p1920×10804.5–6 Mbps
4K3840×216012–20 Mbps (AV1/HEVC ~40–50% less)

Netflix uses per-title / per-shot encoding — the ladder is optimised per content (cartoons need far fewer bits than action scenes).

Manifests

Text
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360,CODECS="avc1.4d401e,mp4a.40.2"
360p/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720,CODECS="avc1.4d401f,mp4a.40.2"
720p/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080,CODECS="avc1.640028,mp4a.40.2"
1080p/index.m3u8

Data model

DataStore
Video metadata (title, owner, status, renditions)sharded SQL / Vitess (YouTube uses Vitess on MySQL)
Segments, raw uploads, thumbnailsobject storage, tiered (hot → infrequent → archive for unpopular originals)
Views, likes countersstream aggregation → counter store + cache
Commentswide-column store partitioned by video ID
Watch history / resume positionKV store keyed by user (written every ~10 s from heartbeats)

Protecting content

Signed URLs or tokens (short TTL) for segments; DRM (Widevine, FairPlay, PlayReady) with license servers for premium content; geo-restrictions at the playback API.

5. Cost control

  • Efficient codecs for popular content (AV1 saves bandwidth on the videos that matter most).
  • Lazy transcoding / fewer renditions for long-tail content.
  • Storage tiering; delete intermediate artifacts.
  • ISP-embedded caches reduce transit costs.
  • Spot/preemptible instances for transcoding (jobs are retryable chunks).

6. Trade-offs

DecisionChoice
Streaming protocolHLS/DASH over HTTP (CDN-friendly) vs WebRTC (low latency, hard to scale)
CDNpush pre-positioning (Netflix) vs pull caching (YouTube)
Transcode timingeager for all renditions vs lazy for long tail
View countsapproximate real-time + exact batch reconciliation

Interview questions

0 / 5 marked confident

Answer out loud first, then open the model answer. Mark a question confident only when you could explain it to an interviewer without notes.