Design YouTube Video Streaming Platform
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 DiagramSynthesizing vector architecture diagram...
Functional Requirements
- Resilient Video Upload: Support resumable, chunked multipart uploads for large video files () over unstable networks.
- Automated Transcoding Pipeline (DAG(Directed Acyclic Graph)): Ingest raw source files, split into GOP (Group of Pictures) chunks, transcode into multi-bitrate profiles (), and package into HLS (
.m3u8,.ts) and MPEG-DASH (.mpd,.m4s) formats. - Adaptive Bitrate Streaming (ABR): Deliver media segments dynamically adapting to client bandwidth, device screen resolution, and buffer occupancy without playback interruption.
- Metadata, Search & Discovery: Real-time video metadata indexing, full-text search, view count tracking, likes, and comment threads.
- Video Deduplication & Watermarking: Detection of duplicate uploads via perceptual and cryptographic hashing; dynamic forensic watermarking.
Non-Functional Requirements (SLAs/SLOs)
- High Availability: availability for video playback ( downtime/year); for video ingestion.
- Playback Latency & TTFF (Time-To-First-Frame): globally across CDN edge Points of Presence (PoPs).
- Zero Stall Rate (Rebuffering): of playback sessions experiencing mid-stream buffering events.
- Transcoding Turnaround SLA: Video ready for playback within the video duration for standard priority; for high-priority/breaking creators.
- Storage Durability: 11 9s () 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): active viewers.
- Video Views / Playback Sessions: Average .
- Video Uploads: .
Storage & Bandwidth Footprint
- Average Raw Video Size: Average duration = (). High-quality source bitrate .
- Transcoding Expansion:
- Each video is transcoded into 6 resolution renditions: (), (), (), (), (), ().
- Cumulative Transcoded Bitrate .
- Storage per 10-min transcoded video .
- CDN Egress Bandwidth:
- Average stream watch time at average ().
- Data delivered per view .
- Edge Cache Hit Ratio (CHR): CloudFront Edge targets CHR for media segments (
.ts/.m4s).
3. High-Level Architecture & AWS Component Mapping
Interactive Architecture DiagramSynthesizing vector architecture diagram...
Component Responsibility Breakdown
| Component | AWS Technology | Operational Role & Configuration |
|---|---|---|
| Edge CDN & Caching | Amazon CloudFront + Origin Shield | Caches .m3u8 master playlists (TTL 2s for live, 86400s for VOD) and .ts/.m4s video segments (TTL 1 year, immutable cache-control). |
| Ingestion Storage | Amazon S3 (Raw Ingest) | Configured with S3 Multipart Upload, Transfer Acceleration, and S3 Lifecycle rules to expire raw source files to Glacier Instant Retrieval after 14 days. |
| Transcoding DAG(Directed Acyclic Graph) | AWS Step Functions + AWS Batch | Coordinates chunk boundary detection, parallel GPU transcoding across resolutions, audio track extraction (AAC/Opus), and manifest generation. |
| Transcoded Storage | Amazon S3 (VOD Segments) | Content-addressable storage layout partitioned by video_id/resolution/segment_index.ts. Versioning enabled. |
| Metadata Store | Amazon DynamoDB | Single-table design storing video metadata, channel ownership, processing status, and aggregate statistics. |
| View Counter Buffer | Amazon ElastiCache Redis | In-memory atomic counters (HINCRBY) buffering millions of view events per second before asynchronous batched flushing to DynamoDB. |
| Search Engine | Amazon OpenSearch Service | 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
httpPOST /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)
httpPOST /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 DiagramSynthesizing 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 DynamoDB with On-Demand capacity and DynamoDB Accelerator (DAX).
Partition Key (PK) | Sort Key (SK) | Attributes & Payloads | GSI1-PK / GSI1-SK |
|---|---|---|---|
VIDEO#<video_id> | METADATA | channel_id, title, duration, status (READY), manifest_url, created_at | CHANNEL#<channel_id> / DATE#<created_at> |
VIDEO#<video_id> | RENDITION#1080P | codec: "avc1.64002a", bitrate: 5000000, segment_count: 150, size_bytes: 375000000 | β |
VIDEO#<video_id> | RENDITION#720P | codec: "avc1.4d401f", bitrate: 2500000, segment_count: 150, size_bytes: 187500000 | β |
VIDEO#<video_id> | COUNTER#VIEWS | view_count: 14829340, hourly_delta: 24500, last_flush: 1718000000 | β |
USER#<user_id> | HISTORY#<video_id> | watched_duration_s: 450, last_position_s: 450, updated_at: 1718000100 | USER#<user_id> / UPDATED#<updated_at> |
Unlock Complete Architecture & Production Runbooks
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.