Skip to main content
BLUEPRINT #01Media & Streaming

Design YouTube Video Streaming Platform

Target AWS Architecture:DynamoDBS3ElastiCacheSQS
10-Stage Structure:1. Requirements→2. Sizing→3. Topology→4. Data Model→5. AWS Topology→6. Deep-Dive→7. Failures→8. SRE Playbooks

1. Problem Statement & Scope

System Mission

Design a global-scale video sharing, processing, and streaming platform capable of handling hundreds of thousands of daily video uploads, distributed parallel transcoding across heterogeneous resolutions and codecs (H.264/AVC, H.265/HEVC, AV1, VP9), Adaptive Bitrate (ABR) streaming via HLS and MPEG-DASH, and ultra-low latency global content delivery with high cache hit ratios.

Interactive Architecture Diagram
Synthesizing vector architecture diagram...

Functional Requirements

  1. Resilient Video Upload: Support resumable, chunked multipart uploads for large video files (>50Β GB> 50\text{ GB}) over unstable networks.
  2. Automated Transcoding Pipeline (DAG(Directed Acyclic Graph)): Ingest raw source files, split into GOP (Group of Pictures) chunks, transcode into multi-bitrate profiles (1080p,720p,480p,360p,240p,4K1080\text{p}, 720\text{p}, 480\text{p}, 360\text{p}, 240\text{p}, 4\text{K}), and package into HLS (.m3u8, .ts) and MPEG-DASH (.mpd, .m4s) formats.
  3. Adaptive Bitrate Streaming (ABR): Deliver media segments dynamically adapting to client bandwidth, device screen resolution, and buffer occupancy without playback interruption.
  4. Metadata, Search & Discovery: Real-time video metadata indexing, full-text search, view count tracking, likes, and comment threads.
  5. Video Deduplication & Watermarking: Detection of duplicate uploads via perceptual and cryptographic hashing; dynamic forensic watermarking.

Non-Functional Requirements (SLAs/SLOs)

  • High Availability: 99.99%99.99\% availability for video playback (<52.6Β minutes< 52.6\text{ minutes} downtime/year); 99.95%99.95\% for video ingestion.
  • Playback Latency & TTFF (Time-To-First-Frame): <800Β ms< 800\text{ ms} globally across CDN edge Points of Presence (PoPs).
  • Zero Stall Rate (Rebuffering): <0.5%< 0.5\% of playback sessions experiencing mid-stream buffering events.
  • Transcoding Turnaround : Video ready for playback within 1.5Γ—1.5\times the video duration for standard priority; <0.5Γ—< 0.5\times for high-priority/breaking creators.
  • Storage Durability: 11 9s (99.999999999%99.999999999\%) data durability for master and transcoded video segments.

Out-of-Scope

  • Real-time ultra-low latency interactive live streaming (WebRTC / LL-HLS sub-second live streaming covered in dedicated blueprints).
  • Rights Management & Content ID fingerprinting algorithms (e.g., automated copyright audio spectrogram analysis).
  • In-stream targeted programmatic ad bidding auctions (RTB).

2. Capacity & Scale Estimation

Traffic & Throughput Calculations

  • Daily Active Users (DAU): 100Β Million100\text{ Million} active viewers.
  • Video Views / Playback Sessions: Average 10Β videos/user/dayβ€…β€ŠβŸΉβ€…β€Š1Β BillionΒ views/day10\text{ videos/user/day} \implies 1\text{ Billion views/day}. AverageΒ PlaybackΒ QPS=109Β views86,400Β sβ‰ˆ11,574Β views/sec\text{Average Playback QPS} = \frac{10^9 \text{ views}}{86,400 \text{ s}} \approx 11,574 \text{ views/sec} PeakΒ PlaybackΒ QPSΒ (3Γ—)=35,000Β views/sec\text{Peak Playback QPS (3}\times\text{)} = 35,000 \text{ views/sec}
  • Video Uploads: 500,000Β videoΒ uploads/day500,000\text{ video uploads/day}. AverageΒ UploadΒ QPS=500,00086,400β‰ˆ5.8Β uploads/secΒ (Peak:Β 25Β uploads/sec)\text{Average Upload QPS} = \frac{500,000}{86,400} \approx 5.8 \text{ uploads/sec (Peak: } 25 \text{ uploads/sec)}

Storage & Bandwidth Footprint

  • Average Raw Video Size: Average duration = 10Β minutes10\text{ minutes} (600Β seconds600\text{ seconds}). High-quality source bitrate β‰ˆ40Β Mbpsβ€…β€ŠβŸΉβ€…β€Š3Β GB/rawΒ upload\approx 40\text{ Mbps} \implies 3\text{ GB/raw upload}. DailyΒ RawΒ Ingestion=500,000Γ—3Β GB=1.5Β PB/day\text{Daily Raw Ingestion} = 500,000 \times 3\text{ GB} = 1.5\text{ PB/day}
  • Transcoding Expansion:
    • Each video is transcoded into 6 resolution renditions: 1080p1080\text{p} (5Β Mbps5\text{ Mbps}), 720p720\text{p} (2.5Β Mbps2.5\text{ Mbps}), 480p480\text{p} (1.2Β Mbps1.2\text{ Mbps}), 360p360\text{p} (700Β kbps700\text{ kbps}), 240p240\text{p} (400Β kbps400\text{ kbps}), 144p144\text{p} (250Β kbps250\text{ kbps}).
    • Cumulative Transcoded Bitrate β‰ˆ10.05Β Mbpsβ‰ˆ1.25Β MB/sec\approx 10.05\text{ Mbps} \approx 1.25\text{ MB/sec}.
    • Storage per 10-min transcoded video =600Β sΓ—1.25Β MB/s=750Β MB= 600\text{ s} \times 1.25\text{ MB/s} = 750\text{ MB}. DailyΒ TranscodedΒ Storage=500,000Γ—750Β MB=375Β TB/dayβ€…β€ŠβŸΉβ€…β€Š136.875Β PB/year\text{Daily Transcoded Storage} = 500,000 \times 750\text{ MB} = 375\text{ TB/day} \implies \mathbf{136.875\text{ PB/year}}
  • CDN Egress Bandwidth:
    • Average stream watch time =5Β minutes= 5\text{ minutes} at 720p720\text{p} average (2.5Β Mbpsβ‰ˆ312.5Β KB/s2.5\text{ Mbps} \approx 312.5\text{ KB/s}).
    • Data delivered per view =300Β sΓ—312.5Β KB/s=93.75Β MB= 300\text{ s} \times 312.5\text{ KB/s} = 93.75\text{ MB}. TotalΒ DailyΒ EgressΒ Data=109Γ—93.75Β MB=93.75Β PB/day\text{Total Daily Egress Data} = 10^9 \times 93.75\text{ MB} = 93.75\text{ PB/day} AverageΒ EgressΒ Bandwidth=93.75Γ—1015Γ—8Β bits86,400Β sβ‰ˆ8.68Β TbpsΒ (Peak:Β 25Β Tbps)\text{Average Egress Bandwidth} = \frac{93.75 \times 10^{15} \times 8 \text{ bits}}{86,400 \text{ s}} \approx \mathbf{8.68\text{ Tbps (Peak: } 25\text{ Tbps)}}
  • Edge Cache Hit Ratio (CHR): CloudFront Edge targets β‰₯98%\ge 98\% CHR for media segments (.ts/.m4s). OriginΒ ShieldΒ /Β S3Β OriginΒ Egress=8.68Β TbpsΓ—(1βˆ’0.98)=173.6Β Gbps\text{Origin Shield / S3 Origin Egress} = 8.68\text{ Tbps} \times (1 - 0.98) = \mathbf{173.6\text{ Gbps}}

3. High-Level Architecture & AWS Component Mapping

Interactive Architecture Diagram
Synthesizing vector architecture diagram...

Component Responsibility Breakdown

ComponentAWS TechnologyOperational Role & Configuration
Edge CDN & CachingAmazon CloudFront + Origin ShieldCaches .m3u8 master playlists ( 2s for live, 86400s for VOD) and .ts/.m4s video segments ( 1 year, immutable cache-control).
Ingestion Storage (Raw Ingest)Configured with Multipart Upload, Transfer Acceleration, and Lifecycle rules to expire raw source files to Glacier Instant Retrieval after 14 days.
Transcoding DAG(Directed Acyclic Graph) + AWS BatchCoordinates chunk boundary detection, parallel GPU transcoding across resolutions, audio track extraction (AAC/Opus), and manifest generation.
Transcoded Storage (VOD Segments)Content-addressable storage layout partitioned by video_id/resolution/segment_index.ts. Versioning enabled.
Metadata Store storing video metadata, channel ownership, processing status, and aggregate statistics.
View Counter Buffer In-memory atomic counters (HINCRBY) buffering millions of view events per second before asynchronous batched flushing to .
Search EngineAmazon BM25 full-text title/tag search, lexical tokenization, and vector search embeddings for semantic video recommendations.

4. API Interface Design & Wire Protocols

1. Initialize Multipart Video Upload

http
POST /v1/videos/uploads/initialize HTTP/1.1
Host: api.youtube.aws.internal
Authorization: Bearer <jwt_token>
Content-Type: application/json

{
  "title": "Deep Dive into Distributed Consensus",
  "description": "Exhaustive exploration of Raft and Paxos algorithms.",
  "category_id": 28,
  "privacy": "PUBLIC",
  "file_name": "consensus_4k_master.mov",
  "file_size_bytes": 4294967296,
  "chunk_size_bytes": 10485760,
  "total_parts": 410,
  "content_type": "video/quicktime"
}

Response: 201 Created

json
{
  "video_id": "vid_998124a87c1",
  "upload_id": "s3_upload_abc123xyz789",
  "part_urls": [
    {
      "part_number": 1,
      "presigned_url": "https://s3.us-east-1.amazonaws.com/raw-ingest/vid_998124a87c1?partNumber=1&uploadId=s3_upload_abc123xyz789&X-Amz-Signature=..."
    },
    {
      "part_number": 2,
      "presigned_url": "https://s3.us-east-1.amazonaws.com/raw-ingest/vid_998124a87c1?partNumber=2&uploadId=s3_upload_abc123xyz789&X-Amz-Signature=..."
    }
  ],
  "expires_in_seconds": 86400
}

2. Complete Multipart Upload & Trigger Transcoding DAG(Directed Acyclic Graph)

http
POST /v1/videos/uploads/complete HTTP/1.1
Host: api.youtube.aws.internal
Authorization: Bearer <jwt_token>
Content-Type: application/json

{
  "video_id": "vid_998124a87c1",
  "upload_id": "s3_upload_abc123xyz789",
  "parts": [
    {"part_number": 1, "etag": "\"d41d8cd98f00b204e9800998ecf8427e\""},
    {"part_number": 2, "etag": "\"0cc175b9c0f1b6a831c399e269772661\""}
  ]
}

Response: 202 Accepted

json
{
  "video_id": "vid_998124a87c1",
  "status": "PROCESSING",
  "estimated_transcode_seconds": 180,
  "status_check_url": "/v1/videos/vid_998124a87c1/status"
}

3. Master HLS Playlist Manifest (master.m3u8)

Delivered via CloudFront edge:

m3u8
#EXTM3U
#EXT-X-VERSION:6

# 1080p Profile (AVC1 / High Profile @ Level 4.2)
#EXT-X-STREAM-INF:BANDWIDTH=5000000,AVERAGE-BANDWIDTH=4500000,RESOLUTION=1920x1080,FRAME-RATE=60.000,CODECS="avc1.64002a,mp4a.40.2"
1080p/index.m3u8

# 720p Profile (AVC1 / Main Profile @ Level 3.1)
#EXT-X-STREAM-INF:BANDWIDTH=2500000,AVERAGE-BANDWIDTH=2200000,RESOLUTION=1280x720,FRAME-RATE=30.000,CODECS="avc1.4d401f,mp4a.40.2"
720p/index.m3u8

# 480p Profile (AVC1 / Main Profile @ Level 3.0)
#EXT-X-STREAM-INF:BANDWIDTH=1200000,AVERAGE-BANDWIDTH=1000000,RESOLUTION=854x480,FRAME-RATE=30.000,CODECS="avc1.4d401e,mp4a.40.2"
480p/index.m3u8

# 360p Profile (AVC1 / Baseline Profile @ Level 3.0)
#EXT-X-STREAM-INF:BANDWIDTH=700000,AVERAGE-BANDWIDTH=600000,RESOLUTION=640x360,FRAME-RATE=30.000,CODECS="avc1.42e01e,mp4a.40.2"
360p/index.m3u8

5. Data Models & Storage Architecture

Interactive Architecture Diagram
Synthesizing vector architecture diagram...

DynamoDB Single-Table Schema (YouTubeCoreTable)

To achieve single-digit millisecond latency at petabyte scale, video metadata, channel relationships, and rendition profiles are consolidated into with On-Demand capacity and ().

() ()Attributes & PayloadsGSI1- / GSI1-
VIDEO#<video_id>METADATAchannel_id, title, duration, status (READY), manifest_url, created_atCHANNEL#<channel_id> / DATE#<created_at>
VIDEO#<video_id>RENDITION#1080Pcodec: "avc1.64002a", bitrate: 5000000, segment_count: 150, size_bytes: 375000000β€”
VIDEO#<video_id>RENDITION#720Pcodec: "avc1.4d401f", bitrate: 2500000, segment_count: 150, size_bytes: 187500000β€”
VIDEO#<video_id>COUNTER#VIEWSview_count: 14829340, hourly_delta: 24500, last_flush: 1718000000β€”
USER#<user_id>HISTORY#<video_id>watched_duration_s: 450, last_position_s: 450, updated_at: 1718000100USER#<user_id> / UPDATED#<updated_at>

Part 2: Production Deep-Dive Locked1 Coin = 24 Hours

Unlock Complete Architecture & Production Runbooks

Your Balance:40 Coins

You have explored the free architectural preview (~48%). Spend 1 Coin to unlock the remaining 6 production deep-dive sections for a full 24 hours.

Sections Included in This 24-Hour Pass:
6. Core Algorithms & Deep-Dive Workflows
7. Architectural Trade-Off Matrix & Primitive Links
8. Critical Failure Modes, Resiliency & Edge Cases
9. Production Pitfalls & Anti-Patterns (The "Top 5 Gotchas")
10. Production Runbook & Observability Guide
11. System Design Interview Rubric & Deep-Dive Strategy
Keeps page unlocked for exactly 24 hoursSpend coins to fund LLM & compute infrastructure