Designing Netflix / YouTube - Video Streaming Platform

Difficulty: Advanced Topics: Video Encoding Pipeline, CDN, Adaptive Bitrate Streaming, Recommendation Engine, Content Catalog Asked at: Netflix, YouTube, Disney+, Amazon Prime Video, Hotstar · Prerequisites: CDN and Message Queues


1. Understanding the Problem

Netflix is a video streaming platform that lets content creators upload video, encodes it into dozens of format/resolution/bitrate combinations, distributes it globally via CDN, and streams it to users with adaptive quality based on their connection speed.
💡 A CDN (content delivery network) is a fleet of servers that keep copies of your files close to users, so a viewer in Jakarta downloads from a machine in Jakarta instead of one in Virginia. Bitrate is how many bits per second a video stream consumes - higher bitrate, better picture, more bandwidth. The system serves 40M+ concurrent streams at peak, each a unique video at a unique bitrate. The hardest parts: encoding pipeline (converting one upload into 100+ playable variants), CDN distribution (getting the right bits to the right edge node before the user needs them), and recommendations (deciding what to show each user from a catalog of 15,000+ titles).


2. Naive First Cut

flowchart LR
    Client["Smart TV App"]
    API["API Server"]
    DB["Postgres DB"]
    Files["File Server"]

    Client --> API
    API --> DB
    API --> Files

How this breaks:

  • Single file server can’t serve 40M concurrent streams - bandwidth alone would be 200 Tbps
    💡 Tbps = terabits per second. A single server’s network card tops out in the tens of gigabits, which is thousands of times less, so this is not a “buy a bigger box” problem - the traffic has to be spread across many machines in many places.
  • No encoding pipeline - raw 4K master files are too large (50GB per hour of content) to stream directly
  • No adaptive quality - users on 3G get buffer wheels, users on fiber get potato quality
  • Centralized serving means 500ms+ latency for users far from origin (India streaming from US-West)
  • No personalization - everyone sees the same homepage, engagement drops
  • Single DB can’t handle 40M concurrent session lookups + play position tracking

The rest of the doc evolves this into a globally distributed streaming platform with intelligent encoding, edge delivery, and personalized recommendations.


3. Prior Art We’re Drawing From

  • Netflix Open Connect - Netflix’s own CDN: custom hardware appliances (OCAs) deployed inside ISP networks. Serves 95%+ of traffic from within the ISP, eliminating internet transit costs. Pre-positions content overnight based on popularity predictions. (Netflix Open Connect overview)
  • YouTube Vitess (Video Metadata at Scale) - Sharded MySQL via Vitess for video metadata, serving billions of queries/day. Demonstrates that video catalogs need a horizontally scalable metadata tier. (Vitess.io)
  • Netflix Zuul (API Gateway) - Edge gateway handling auth, routing, canary deployments, and load shedding for 200M+ users. Shows why a smart edge layer is critical for streaming. (Netflix Zuul blog)
  • Netflix Cosmos (Encoding Pipeline) - Microservice-based media processing platform replacing the monolithic encoder. Uses per-title encoding to optimize bitrate per scene complexity. (Netflix Tech Blog - Cosmos)
  • Netflix Recommendations (Two-Stage Ranking) - Candidate generation via collaborative filtering, then re-ranking via deep learning. Row-based homepage layout driven by ML. (Netflix Tech Blog - Recommendations)

In simple terms: Instead of encoding every video the same way, analyze each scene separately. Action scenes get more bits (complex), talking-head scenes get fewer bits (simple). Result: consistent visual quality throughout without wasting bandwidth on easy scenes.


4. Functional Requirements

Core (Top 3)

  1. Upload and encode video content - content team uploads master files; system encodes into multiple resolutions, bitrates, and codecs
  2. Stream video with adaptive bitrate - users watch content with quality that adjusts to their bandwidth in real-time
  3. Personalized recommendations - homepage shows titles ranked by predicted relevance for each user

Below the Line

  • User profiles and parental controls
  • Offline downloads
  • Subtitles and multi-language audio
  • Watch party (synchronized playback)
  • Content licensing and regional availability

5. Non-Functional Requirements

Core

NFR Target
Start Playback Time to first frame < 2 seconds globally
Buffer-free 99% of streams play without rebuffering
Scale 40M+ concurrent streams during peak (Sunday evening)
Availability 99.99% - downtime during prime time is front-page news