System Design (50 Qs)•Part 2: Real-World High-Scale Architecture Problems (11 - 25)
Design a Global Video Streaming Platform (YouTube / Netflix).
In Simple Words: Ingest raw video files uploaded by creators, transcode them into multiple resolutions and bitrates, and stream playback smoothly to diverse devices across variable network bandwidths.
Core Architecture & Streaming Protocols:
- HLS (HTTP Live Streaming) / MPEG-DASH:
- Videos are split into small chunks (2–6 seconds each).
- A manifest file (
.m3u8) lists all available resolutions (480p, 720p, 1080p, 4K) and chunk URLs. - Video player dynamically switches bitrates based on real-time client network bandwidth (Adaptive Bitrate Streaming).
- Storage Tiering:
- Raw uploads → AWS S3 Standard.
- Transcoded chunks → S3 + Global Edge CDN (Cloudflare/Fastly).
- Cold, unwatched archive videos → AWS S3 Glacier Flexible.
typescript
// Sample M3U8 Master Playlist Concept for Adaptive Bitrate Streaming
const masterPlaylist = `
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360
360p/stream.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1400000,RESOLUTION=842x480
480p/stream.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720
720p/stream.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080
1080p/stream.m3u8
`;