System DesignSep 28, 2026⏱️ 3 min read
Design YouTube: Adaptive Bitrate Streaming, DAG Transcoding & Edge CDN Delivery

Design YouTube: Adaptive Bitrate Streaming, DAG Transcoding & Edge CDN Delivery

Engineering Video at Petabyte Scale

Video streaming combines two extreme engineering challenges: massive storage & transcoding compute on upload, and ultra-high global network egress during playback (handling tens of terabits per second across billions of daily views).
YouTube Video Streaming & Transcoding Architecture

YouTube Video Streaming & Transcoding Architecture


1. Upload Flow: Never Proxy Gigabytes Through API Servers

Uploading a 4 GB raw video through your Python or Node.js API servers ties up worker threads for minutes.
  1. Client asks API servers for a Presigned Object Storage URL (AWS S3 / GCS).
  2. Client uploads video chunks directly to Original Storage (multipart/resumable upload) so dropped Wi-Fi resumes seamlessly.
  3. Completion triggers a Transcoding Queue while metadata writes to SQL (MySQL/Vitess with read replicas).

2. The DAG Transcoding Pipeline

Different users watch on 4K smart TVs over fiber and budget phones on 3G trains. Every uploaded video must be encoded across multiple codecs (H.264, VP9, AV1) and resolutions (360p, 480p, 720p, 1080p, 4K).

Split by GOP for Parallel Encoding

Instead of a single worker spending 3 hours encoding a 2-hour movie sequentially:
  1. Preprocessor splits the video at GOP (Group of Pictures) boundaries into tiny independent 2–10 second segments.
  2. A DAG Scheduler fans out parallel tasks across transcoding workers:
    • Audio track extraction + normalization
    • Video segment encoding (360p..4K) in parallel
    • Watermarking, closed-caption ASR, and thumbnail generation
  3. Segments reassemble into streaming playlists (HLS .m3u8 or MPEG-DASH .mpd) stored in Transcoded S3 buckets.

3. Adaptive Bitrate Streaming (ABR) & CDN Economics

How ABR Prevents Buffering

The video player downloads a lightweight manifest file (.m3u8) listing segmented video URLs at each bitrate tier. Every 2–4 seconds, the player measures real-time download bandwidth—seamlessly dropping from 1080p to 480p mid-sentence if the user enters an elevator, then stepping back up without pausing.

Taming Massive CDN Bandwidth Bills

Serving 100% of views from third-party CDNs costs millions monthly. Optimize aggressively:
  • 80/20 Cache Rule: Keep the top 20% viral/popular videos pinned on CDN edge PoPs (accounting for >80% of all traffic).
  • Serve Long-Tail from Origin Storage: Rarely watched 5-year-old videos with 2 views/year stream on-demand from origin object storage rather than polluting expensive edge SSDs.
  • Region-Aware Transcoding: Don't waste GPU cycles encoding niche videos in 4K or exotic codecs until view counts cross a popularity threshold.
  • Safety & Anti-Leeching: Serve video segments via short-lived Signed CDN URLs / Cookies and DRM tokenization.

Share this article

Comments