Skip to content
advancedPhase 52 · HLD Case Studies

Netflix

Design Netflix's content delivery and recommendation system.

2h
0 problems
Topic Progress0%

Requirements & Scope

Functional Requirements

Core Features

  1. Browse Catalog — Users explore content by genre, category, trending, new releases, and "Top 10" lists
  2. Search — Full-text search across titles, actors, directors, genres with autocomplete and typo tolerance
  3. Stream Video — Play video content with adaptive quality, pause/resume, seek, and subtitle support
  4. Multiple Profiles — Up to 5 profiles per account with personalized recommendations per profile
  5. Watchlist — Users add/remove titles for later viewing across devices
  6. Continue Watching — Resume playback from the exact position across any device
  7. Download for Offline — Download select titles to mobile devices for offline viewing
  8. Parental Controls — Content filtering by maturity rating per profile

Non-Functional Requirements

Requirement Target
Availability 99.99% uptime (< 52 min downtime/year)
Latency Video startup < 2 seconds globally
Throughput 15% of total global internet bandwidth during peak
Concurrency 200M+ active subscribers simultaneously
Scalability Linear scaling with subscriber growth
Consistency Eventually consistent for catalog; strong for user state

Key Constraints

  • Video files are large (GBs per title for 4K)
  • Global audience across 190+ countries
  • Peak hours: 8PM-midnight local time in each region
  • Must handle 100M+ hours of content viewed daily
  • Device diversity: Smart TVs, phones, tablets, browsers, gaming consoles

Capacity Estimation

Assumptions:
- 200M subscribers, 80% active monthly
- Average viewing: 2 hours/day
- Average bitrate: 5 Mbps (1080p)
- Video chunks: 5 seconds each

Bandwidth per user: 5 Mbps = 0.625 MB/s
Peak concurrent: ~50M users
Peak bandwidth: 50M * 0.625 MB/s = 31.25 TB/hour

Storage per movie (2 hours, 1080p, H.264):
  - Bitrate: 5 Mbps
  - Size: 5 Mbps * 7200s = 4.5 GB per title per resolution
  - Average 5 resolutions per title: 22.5 GB per title
  - 15,000 titles: ~337 TB raw content storage

Cache hit target: 95%+ of requests served from CDN edge

Content Delivery & CDN (Open Connect)

Netflix Open Connect Architecture

Netflix built its own CDN called Open Connect — purpose-built for video streaming rather than using public CDNs like Akamai or CloudFront.

Open Connect Appliance (OCA)

Netflix deploys custom storage/serving appliances (OCAs) inside ISP networks:

┌─────────────────────────────────────────────────────────┐
│                    Netflix Origin (S3)                  │
│              (Video files, all resolutions)             │
└──────────────────────┬──────────────────────────────────┘
                       │
         ┌─────────────┼─────────────────┐
         ▼             ▼                 ▼
   ┌──────────┐  ┌──────────┐      ┌──────────┐
   │ Regional │  │ Regional │ ...  │ Regional │
   │ Pop #1   │  │ Pop #2   │      │ Pop #N   │
   │(LA)      │  │(London)  │      │(Tokyo)   │
   └────┬─────┘  └────┬─────┘      └────┬─────┘
        │              │                 │
   ┌────┴─────┐  ┌────┴─────┐      ┌────┴─────┐
   │ ISP Peer │  │ ISP Peer │      │ ISP Peer │
   │ OCA      │  │ OCA      │      │ OCA      │
   │(inside   │  │(inside   │      │(inside   │
   │ ISP DC)  │  │ ISP DC)  │      │ ISP DC)  │
   └──────────┘  └──────────┘      └──────────┘
        │              │                 │
   ┌────┴─────┐  ┌────┴─────┐      ┌────┴─────┐
   │ End      │  │ End      │      │ End      │
   │ Users    │  │ Users    │      │ Users    │
   └──────────┘  └──────────┘      └──────────┘

How Open Connect Works

  1. Placement: Netflix negotiates with ISPs worldwide to place OCA servers inside their data centers (colocation)
  2. Content Popularity Analysis: ML models predict which content will be popular in each region
  3. Pre-positioning: Popular content is pushed to OCAs during off-peak hours (typically 2-6 AM)
  4. Routing: Netflix's control plane directs users to the optimal OCA based on:
    • Geographic proximity
    • ISP routing efficiency
      n - Current load on each OCA
    • Content availability on that OCA

Multi-Tier CDN Hierarchy

Tier 1: Origin (S3) ─── All content, all resolutions
     │
Tier 2: Regional Points of Presence ─── Top 5000 titles per region
     │
Tier 3: Open Connect Appliances (inside ISPs) ─── Top 1000 titles per ISP cluster
     │
Tier 4: Client-side cache ─── Current session chunks

OCA Specifications

Spec Detail
Storage 100-200 TB per appliance
Throughput 10+ Gbps per appliance
Form factor Custom 2U-4U rack server
Content ~2000-5000 most popular titles per region
Lifecycle 3-4 year refresh cycle
Deployed 1000s of OCAs across 6000+ ISP locations globally

Request Flow for Video Playback

1. User clicks "Play" on title X
2. Client → Netflix API Gateway → Streaming Service
3. Streaming Service checks: Is this content cached on a nearby OCA?
4. If YES → Return OCA URL + manifest file → Client streams from OCA
5. If NO → Check Regional PoP → If there, stream from PoP
6. If still NO → Stream from Origin (rare, only for very long-tail content)
7. The client receives a redirect URL pointing to the optimal OCA
8. Client fetches video chunks from that OCA

Benefits of Open Connect

  • Cost: Eliminates CDN fees by owning infrastructure (saves $100M+/year)
  • Performance: Direct ISP peering reduces latency to < 10ms for most users
  • Control: Custom hardware optimized specifically for video serving
  • Scalability: New OCAs added proportionally to ISP subscriber growth
  • Reliability: Multiple tiers ensure content availability even if OCAs fail

Streaming Architecture

Adaptive Bitrate Streaming (ABR)

Netflix uses HTTP-based adaptive bitrate streaming. The core idea: split video into small chunks and let the client dynamically switch between quality levels based on network conditions.

Video Processing Pipeline

Raw Video Upload
     │
     ▼
┌─────────────────────────────────────┐
│         Transcoding Service          │
│  ┌─────────────────────────────────┐ │
│  │ 1. Decode source video          │ │
│  │ 2. Scale to multiple resolutions│ │
│  │ 3. Encode with multiple codecs  │ │
│  │ 4. Generate multiple bitrates   │ │
│  │ 5. Create manifest files        │ │
│  └─────────────────────────────────┘ │
└──────────────────┬──────────────────┘
                   ▼
┌─────────────────────────────────────┐
│           S3 Storage                │
│  video/title_id/                    │
│    ├── 1080p_6000k.mp4              │
│    ├── 720p_3000k.mp4               │
│    ├── 480p_1500k.mp4               │
│    ├── 360p_1000k.mp4               │
│    ├── manifest.mpd (DASH)          │
│    └── manifest.m3u8 (HLS)          │
└─────────────────────────────────────┘

Bitrate Ladder

Netflix defines a bitrate ladder — a set of resolution/bitrate combinations for each video:

Resolution Video Bitrate Audio Bitrate Codec Use Case
3840×2160 (4K UHD) 16 Mbps 192 kbps H.265/HEVC 4K displays
1920×1080 (Full HD) 6 Mbps 192 kbps H.264/H.265 Standard HD
1280×720 (HD) 3 Mbps 128 kbps H.264 Mobile/tablet
854×480 (SD) 1.5 Mbps 128 kbps H.264 Slow connections
640×360 750 kbps 64 kbps H.264 Low bandwidth
426×240 400 kbps 64 kbps H.264 Ultra-low bandwidth

Video Chunking

┌────────────────────────────────────────────────────┐
│              Full Movie (2 hours)                  │
│  Total: 120 minutes * 60 seconds = 7200 seconds   │
└────────────────────────────────────────────────────┘
                    │
                    ▼ Split into chunks
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │...│   │   │ 360│
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
 Each chunk: 2-10 seconds (Netflix typically uses 5 seconds)
 Each chunk exists at EVERY bitrate level

Manifest Files

DASH Manifest (MPD) — XML-based, describes all available representations:

<?xml version="1.0" encoding="UTF-8"?>
<MPD mediaPresentationDuration="PT7200S">
  <Period>
    <AdaptationSet mimeType="video/mp4">
      <Representation id="1080p" bandwidth="6000000" width="1920" height="1080">
        <SegmentTemplate timescale="1" media="1080p_$Number$.m4s" duration="5"/>
      </Representation>
      <Representation id="720p" bandwidth="3000000" width="1280" height="720">
        <SegmentTemplate timescale="1" media="720p_$Number$.m4s" duration="5"/>
      </Representation>
      <Representation id="480p" bandwidth="1500000" width="854" height="480">
        <SegmentTemplate timescale="1" media="480p_$Number$.m4s" duration="5"/>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>

HLS Manifest (M3U8) — Apple's format, widely supported:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:5
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:5.0,
1080p_0.m4s
#EXTINF:5.0,
1080p_1.m4s
#EXTINF:5.0,
1080p_2.m4s

ABR Algorithm (Netflix's BBA - Buffer-Based Approach)

The client uses a buffer-based algorithm to decide which bitrate to request:

Buffer Level
    │
    │  ┌─────────────────────────────────────────┐
    │  │         Safe Zone (switch UP allowed)    │
    │  │  High bitrate: buffer > 60% full         │
    │  └─────────────────────────────────────────┘
    │
    │  ┌─────────────────────────────────────────┐
    │  │         Normal Zone (maintain current)    │
    │  │  Buffer 20%-60% full                     │
    │  └─────────────────────────────────────────┘
    │
    │  ┌─────────────────────────────────────────┐
    │  │         Danger Zone (switch DOWN)        │
    │  │  Buffer < 20% full                       │
    │  └─────────────────────────────────────────┘
    │
    └────────────────────────────────────────── Time

ABR Decision Logic:

def select_bitrate(buffer_level, available_bitrates, current_bitrate):
    buffer_percentage = buffer_level / MAX_BUFFER * 100
    
    if buffer_percentage < 10:
        # Emergency: drop to lowest available bitrate
        return min(available_bitrates)
    elif buffer_percentage < 30:
        # Conservative: stay or go lower
        return min(available_bitrates)
    elif buffer_percentage > 70:
        # Aggressive: try highest available
        return max(available_bitrates)
    else:
        # Moderate: maintain current or incrementally increase
        return current_bitrate

Startup Latency Optimization

Netflix targets < 2 second startup time:

  1. Pre-fetching: While browsing, prefetch manifests and first few chunks of likely-to-play titles
  2. Manifest caching: Cache manifest files at CDN edge
  3. Short first chunk: First chunk can be smaller (2-3 seconds) for faster start
  4. Parallel fetching: Download audio and video segments simultaneously
  5. TCP warmup: Maintain persistent connections to OCAs

Personalization & Recommendations

Netflix Recommendation System

Netflix's recommendation engine drives 80% of content watched on the platform. It's their most critical competitive advantage.

Recommendation System Architecture

┌─────────────────────────────────────────────────────────┐
│                    Data Sources                         │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐  │
│  │ Viewing  │ │ Search   │ │ Ratings  │ │ Device   │  │
│  │ History  │ │ Queries  │ │ (thumbs) │ │ Context  │  │
│  └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘  │
└───────┼─────────────┼────────────┼─────────────┼────────┘
        │             │            │             │
        ▼             ▼            ▼             ▼
┌─────────────────────────────────────────────────────────┐
│              Feature Engineering Pipeline               │
│  ┌─────────────────────────────────────────────────┐    │
│  │ - User genre preferences (weighted by recency)  │    │
│  │ - Viewing time patterns (weekday/weekend)       │    │
│  │ - Device preferences (TV vs mobile)             │    │
│  │ - Time of day patterns                          │    │
│  │ - Completion rates per title                    │    │
│  │ - Skip/replay patterns                          │    │
│  └─────────────────────────────────────────────────┘    │
└────────────────────────┬────────────────────────────────┘
                         │
                         ▼
┌─────────────────────────────────────────────────────────┐
│              ML Model Ensemble                          │
│  ┌──────────────┐ ┌──────────────┐ ┌──────────────┐    │
│  │ Collaborative│ │Content-Based │ │ Deep Learning │    │
│  │ Filtering    │ │ Filtering    │ │ (Neural Net)  │    │
│  └──────┬───────┘ └──────┬───────┘ └──────┬───────┘    │
│         └────────────────┼────────────────┘             │
│                          │                              │
│                    ┌─────┴─────┐                        │
│                    │  Blending  │                        │
│                    │  Layer     │                        │
│                    └─────┬─────┘                        │
└──────────────────────────┼──────────────────────────────┘
                           │
                           ▼
┌─────────────────────────────────────────────────────────┐
│              Personalized Results                       │
│  Row 1: "Top Picks for [User]"                         │
│  Row 2: "Because you watched [Title]"                   │
│  Row 3: "Trending Now" (personalized order)             │
│  Row 4: "New Releases" (personalized selection)         │
│  Row 5: "Watch It Again"                               │
│  Row 6: Genre-specific rows (personalized)              │
└─────────────────────────────────────────────────────────┘

Collaborative Filtering

User-User Collaborative Filtering:

  • Find users similar to you (based on viewing history)
  • Recommend content they watched that you haven't

Item-Item Collaborative Filtering:

  • Find content similar to what you've watched
  • Based on what other users with similar taste also watched
User-Item Matrix (implicit feedback - viewing hours):

              Title A  Title B  Title C  Title D  Title E
User 1           10       0        8        0        3
User 2            0       5        0        7        0
User 3            9       0        7        0        2
User 4            0       6        0        8        0

→ User 1 similar to User 3 (both watch A & C)
→ Recommend Title D to User 1 (User 3's pattern)

Content-Based Filtering

Uses metadata and content features:

Feature Example
Genre Sci-Fi, Thriller, Drama
Sub-genre Cyberpunk, Psychological, Period Drama
Cast Actor X, Director Y
Visual features Dark tones, Fast-paced scenes
Audio features Orchestral soundtrack, Minimal score
Metadata Year, Country, Language
NLP on synopsis Keywords extracted from description

Deep Learning Model (Neural Collaborative Filtering)

Netflix uses a combination of:

┌─────────────────────────────────────────────┐
│         Neural Collaborative Filtering       │
│                                             │
│  Input: User embedding + Item embedding     │
│      │              │                       │
│      ▼              ▼                       │
│  ┌────────┐    ┌────────┐                   │
│  │ User   │    │ Item   │                   │
│  │ Vector │    │ Vector │                   │
│  │(128-d) │    │(128-d) │                   │
│  └───┬────┘    └───┬────┘                   │
│      │             │                        │
│      ▼             ▼                        │
│  ┌─────────────────────┐                    │
│  │   Concatenation     │                    │
│  │   (256-d vector)    │                    │
│  └──────────┬──────────┘                    │
│             │                               │
│  ┌──────────▼──────────┐                    │
│  │  Dense Layer (128)  │                    │
│  │  + ReLU             │                    │
│  └──────────┬──────────┘                    │
│             │                               │
│  ┌──────────▼──────────┐                    │
│  │  Dense Layer (64)   │                    │
│  │  + ReLU             │                    │
│  └──────────┬──────────┘                    │
│             │                               │
│  ┌──────────▼──────────┐                    │
│  │  Output (1)         │                    │
│  │  Watch probability  │                    │
│  └─────────────────────┘                    │
└─────────────────────────────────────────────┘

Homepage Personalization

Netflix personalizes every element:

  1. Row generation: Which rows appear (genre, mood, cast-based)
  2. Row ordering: Which rows are higher priority
  3. Title ordering: Which titles appear first in each row
  4. Artwork selection: Personalized thumbnail art per title per user
    • User who watches romance → sees romantic scene thumbnail
    • User who watches action → sees action scene thumbnail for same title

ML Pipeline

┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐
│ Real-time │───▶│ Feature  │───▶│ Model    │───▶│ Serving  │
│ Event     │    │ Store    │    │ Training │    │ Layer    │
│ Stream    │    │ (Redis)  │    │ (GPU)    │    │ (API)    │
└──────────┘    └──────────┘    └──────────┘    └──────────┘
    Kafka        Cassandra        SageMaker       EVCache

Retraining frequency: Daily (batch) + hourly (online learning)
A/B testing: Every model change tested on small user segment first

Metrics & Evaluation

Metric Definition
Play rate % of impressions that result in a play
Completion rate % of viewers who finish the title
Discovery rate % of plays from non-search (browse/recommend)
Retention Monthly subscriber retention rate
Diversity Variety of genres/content in recommendations
Novelty How much content is "discovered" vs. already known
Surprise Content outside user's typical patterns that they enjoy

Practice Problems

0/3solved
Design Netflix (Design Netflix) System

Design a scalable Netflix (Design Netflix) system. Cover high-level architecture, data model, and API design.

Solution
// Complete system design:
// - Functional + Non-functional requirements
// - Capacity estimation
// - Data model (SQL/NoSQL choice)
// - API endpoints
// - Component architecture
// - Scaling strategy
// - Monitoring & reliability
Netflix (Design Netflix) Scaling

How would you scale Netflix (Design Netflix) to handle 10x the current load? Identify bottlenecks and solutions.

Solution
// Scaling approach:
// 1. Load balancing
// 2. Database sharding/replication
// 3. Cache layer (Redis)
// 4. CDN for static assets
// 5. Async processing (queues)
// 6. Microservices decomposition
Netflix (Design Netflix) Failure Modes

Analyze potential failure modes for Netflix (Design Netflix) and design mitigation strategies.

Solution
// Failure mitigation:
// 1. Redundancy (multi-AZ)
// 2. Circuit breakers
// 3. Retry with backoff
// 4. Dead letter queues
// 5. Health checks
// 6. Graceful degradation

Quiz

1. What is Netflix's CDN called and how does it differ from traditional CDNs?

Question 1 options

2. How does adaptive bitrate streaming work at Netflix?

Question 2 options

3. Why does Netflix split video into 2-10 second chunks instead of streaming the entire file?

Question 3 options

4. What percentage of content watched on Netflix is driven by the recommendation engine?

Question 4 options

5. How does Netflix use personalized artwork in recommendations?

Question 5 options

Flashcards

Question

What is Netflix Open Connect?

Answer

Netflix's custom-built CDN that places storage/serving appliances (OCAs) directly inside ISP data centers. Each OCA stores 100-200TB of the most popular content for that ISP's region, delivering 10+ Gbps throughput.

Question

What is a bitrate ladder?

Answer

A predefined set of resolution/bitrate combinations that each video is encoded to. Example: 4K@16Mbps, 1080p@6Mbps, 720p@3Mbps, 480p@1.5Mbps. The client selects from this ladder based on network conditions.

Question

What is BBA (Buffer-Based Approach) in ABR?

Answer

Netflix's adaptive bitrate algorithm that makes quality decisions based on buffer occupancy rather than bandwidth estimation. High buffer = can afford higher quality; low buffer = must drop quality to prevent rebuffering.

Question

How does Netflix pre-position content on OCAs?

Answer

ML models predict which titles will be popular in each region. During off-peak hours (2-6 AM), popular content is pushed from origin S3 to OCAs, ensuring high cache hit rates during peak viewing hours.

Question

What is collaborative filtering in Netflix recommendations?

Answer

Finding users with similar viewing patterns and recommending content they watched that you haven't. Can be user-user (find similar users) or item-item (find similar content based on co-viewing patterns).

Question

Why use manifest files (MPD/M3U8) in streaming?

Answer

Manifest files describe all available video representations (resolutions, bitrates, codecs) and their chunk URLs. The client reads the manifest to know what quality options exist and which chunks to request.

Question

How many OCAs has Netflix deployed globally?

Answer

Thousands of OCAs deployed across 6000+ ISP locations in 190+ countries. Netflix handles ~15% of total global internet bandwidth during peak hours.

Revision Notes

Key Takeaways

  • 1.Netflix Open Connect is a custom CDN with appliances inside ISPs - not a traditional third-party CDN
  • 2.Adaptive bitrate streaming uses chunked video (2-10s segments) with client-side quality switching based on buffer level
  • 3.The recommendation system drives 80% of content watched using collaborative filtering, content-based, and deep learning models
  • 4.Video transcoding produces multiple resolutions/codecs per title with a defined bitrate ladder
  • 5.Content is pre-positioned on CDN edges based on ML popularity predictions during off-peak hours
  • 6.Manifest files (DASH MPD / HLS M3U8) describe available quality options and chunk URLs
  • 7.Netflix handles ~15% of global internet bandwidth during peak viewing hours

Interview Tips

  • Start by clarifying scope: are you designing the entire platform or focusing on streaming/CDN/recommendations?
  • Draw the video pipeline early: Upload → Transcode → Store → CDN → Client. This frames all subsequent discussion.
  • Always mention adaptive bitrate streaming - it's the core of video delivery quality
  • Discuss the CDN architecture in detail - Open Connect is Netflix's key technical differentiator
  • For recommendations, explain both collaborative and content-based filtering with concrete examples
  • Address scalability: how does the system handle 200M+ users across 190+ countries?
  • Mention QoE metrics: startup time, buffering ratio, bitrate, and error rate
  • If time allows, discuss personalization beyond recommendations (personalized artwork, UI customization)

Cheat Sheet

Netflix System Design - Cheat Sheet

Architecture Overview

  • API Gateway → Microservices (User, Catalog, Streaming, Recommendation) → Data Stores
  • CDN: Open Connect (custom, ISP-embedded appliances)
  • Storage: S3 (video origin), Cassandra (user data), Elasticsearch (search), EVCache (recommendations cache)

Video Pipeline

  1. Content Ingest → Transcode (multiple resolutions/codecs) → Store in S3 → Push to CDN OCAs
  2. Streaming: Client reads manifest → Requests chunks via HTTP → ABR selects bitrate → Buffer-based algorithm
  3. Chunk size: 2-10 seconds (typically 5s)
  4. Formats: HLS (Apple) + DASH (MPEG) for maximum device compatibility

CDN (Open Connect)

  • Custom appliances inside ISP data centers
  • 100-200TB storage per OCA, 10+ Gbps throughput
  • Content pre-positioned based on ML popularity predictions
  • 3-tier hierarchy: Origin → Regional PoP → ISP OCA
  • Saves Netflix $100M+/year vs third-party CDN

Recommendations

  • 80% of content watched comes from recommendations
  • Techniques: Collaborative filtering, Content-based filtering, Deep learning (Neural CF)
  • Personalizes: row generation, row ordering, title ordering, artwork selection
  • Pipeline: Real-time events → Feature store → Model training → Serving layer

Key Metrics

  • Video startup latency: < 2 seconds
  • Availability: 99.99%
  • Bandwidth: 15% of global internet
  • Concurrent users: 200M+ subscribers

Design Tips

  • Emphasize the CDN architecture (Open Connect is unique to Netflix)
  • Discuss ABR algorithm tradeoffs (buffer-based vs bandwidth-based)
  • Mention personalized artwork as a differentiator
  • Cover scalability through content pre-positioning and caching tiers