System DesignHard• 10 min read• Updated 2026-11-24
Designing YouTube or Netflix: Video Streaming at Scale
Video systems are about physics and economics. A single uncompressed 4K video is hundreds of gigabytes. If you route video uploads through your application servers, your network cards will saturate before you finish the sentence. Here is the blueprint for video ingestion, transcoding DAGs, and adaptive delivery that clears top-tier interviews.
1. Ingestion: Never Route Video Bytes Through API Servers
If a candidate draws an arrow from the client uploading a 20GB video file into an API server, that is an immediate failure point.
API servers are built for small JSON payloads. Streaming gigabytes through them ties up connection threads and exhausts socket buffers.
The correct architecture: The client asks the API for permission to upload. The API validates credentials, allocates an object path, and returns an S3 or GCS pre-signed URL for direct multipart upload. The client uploads chunks directly to cloud object storage. When complete, cloud storage emits an event to an SQS queue to begin processing.
The Ingestion Principle
Heavy binary data flows directly from client to object storage. Metadata and control signals flow through API servers.
2. The Transcoding Pipeline (Directed Acyclic Graph)
Raw uploaded videos arrive in uncompressed formats like ProRes or raw MP4. You cannot stream this directly to a user on a mobile 4G connection.
Transcoding converts video into multiple formats (H.264, VP9, AV1) and resolutions (360p, 720p, 1080p, 4K). Transcoding a 4K movie sequentially takes hours.
The solution is a pipeline DAG (Directed Acyclic Graph):
Step 1: Chunking service splits the video into 2 to 6-second slices at keyframe boundaries.
Step 2: A fleet of worker nodes transcodes chunks in parallel across spot GPU instances.
Step 3: An assembler compiles the transcoded chunks and outputs an HLS or MPEG-DASH manifest file (.m3u8).
Live Technical Interview Practice
Practice this topic on the interactive AI whiteboard
Do not just read the solution. Test your architecture under realistic interview pressure with an AI interviewer probing bottlenecks in real time.
How does Netflix or YouTube stream smoothly when you walk into an elevator with weak Wi-Fi?
They use Adaptive Bitrate Streaming (ABR). The video player reads the master playlist file, which lists URLs for each resolution tier.
The player monitors download speed and buffer fullness on every single 4-second chunk. If bandwidth drops, the player immediately requests the next 4-second chunk at 480p instead of 1080p. The video quality drops slightly, but playback never freezes to buffer.
4. Content Delivery Networks (CDNs) and Cold Storage
Over 90 percent of YouTube videos receive fewer than 50 views per month. You cannot cache petabytes of long-tail video on expensive CDN edge nodes.
Tier 1 (Edge CDN): Stores chunks for the top 5 percent of trending videos directly in POP memory close to viewers.
Tier 2 (Regional Storage): Holds warm videos that get regular traffic.
Tier 3 (Cold Archive): Infrequently accessed videos reside in standard object storage and are pulled into the CDN hierarchy only when requested.
5. Scalable View Counting Without Database Deadlocks
If a viral video gets 100,000 views per second, running UPDATE videos SET views = views + 1 locks the row and crashes the database.
View events stream into Kafka. In-memory stream aggregators (such as Apache Flink or a Redis counter cluster) count views in 15-second tumbling windows.
Every 15 seconds, a single batch update flushes the aggregated delta to persistent storage. This turns 1,500,000 row locks into one clean batch query.
Key Architecture Decisions & Trade-offs
Decision Area
Options Evaluated
Recommendation
Video Upload Path
API gateway relay vs S3 Pre-Signed Direct Upload
Pre-Signed Direct Upload. Prevents media payload saturation on stateless web clusters.
Direct row increment vs Tumbling window aggregation
Tumbling window aggregation. Batches millions of view increments into periodic database flushes.
Frequently Asked Interview Follow-ups
Why split videos into 2 to 6 second chunks instead of 30 seconds?
Shorter chunks let the player adapt quickly when network conditions fluctuate. Long chunks delay adaptation and increase initial playback start latency.
How do you protect copyrighted video uploads?
A fingerprint worker extracts audio and visual hash vectors from uploaded chunks and checks them against a reference copyright database before publishing.
How do you prevent duplicate view counts from bots?
Log view events with client session tokens and IP hashes. Only count a view if playback duration exceeds 30 continuous seconds.
Ready for the interview loop?
Test your design under real pressure
Simulate a full 45-minute technical session on SWEPrep. Diagram architecture on the canvas, justify your trade-offs, and receive instant rubric feedback.