Skip to main content
intermediate

YouTube

Upload → transcode → CDN → recommendations. HLS delivery, ABR ladder, per-title encoding.

Ch 0The scenario
Journey map
YouTube 1 chapters · ~5 min total
Levels:L4 · BeginnerL5 · IntermediateL6 · AdvancedL7 · Senior
1
Foundation
Set the stage. Requirements, math, API contract.
~5 min
The full journey
1 chapters · beginner → super-senior
BeginnerIntermediateAdvancedSenior
Ch 0 · StartClick any chapter to jump →Ch 12 · Defense
Chapter 0
For beginner
5 min read

The scenario

User-generated video at 2.7B MAU — where custom silicon and the recommendation engine converge

Your mentor

Same startup, same engineer #4. Seventh Monday.

Your CTO drops by. "After Netflix, users want a user-generated video feature. Anyone can upload, anyone can watch, anyone can comment. A recommendation feed keeps people engaged. Ship an MVP in 12 weeks."

She pauses. "For context — YouTube processes 500+ hours of video uploaded EVERY MINUTE. 2.7 billion monthly active users. And they invented Vitess (the MySQL sharding proxy) because the read load broke every off-the-shelf database around 2010. If we're going to build this, we need to grasp WHY UGC video is a fundamentally different problem than Netflix's licensed catalog."

Here's the paradigm shift:

Netflix was 100K licensed titles, 300M subs, 200 Tbps peak egress. Solvable with Open Connect Appliances because the catalog is small and predictable — you push tomorrow's popular titles at 3am.

YouTube is 500 hours uploaded per minute — no catalog is fixed. No push algorithm can predict what will be popular. The recommendation engine has to work on ~10^10 videos, most of which have <10 views. The compute cost of encoding UGC (billions of hours of video) is so extreme that YouTube built custom silicon — the Argos Video Coding Unit — to encode 2x-33x faster than commodity CPUs. Reference: Google Cloud blog on Argos VCU.

The recommendation engine is even more consequential. It's an entire ML system that ranks candidates → ranker → then serves 720M hours of watch time per day. Reference: Covington et al., "Deep Neural Networks for YouTube Recommendations" (RecSys 2016) — the canonical two-tower ML paper.

The real 2024 numbers

  • ~2.7B MAU (Statista 2024)
  • ~500+ hours of video uploaded PER MINUTE (DemandSage 2024)
  • ~720M hours watched per day globally
  • ~1 billion hours watched per day including YouTube Shorts
  • ~10 EXABYTES of stored video (10^19 bytes)
  • ~200 PB CDN cache at Google's edge
  • ~$32B ad revenue 2024 (Alphabet Q4 2024)
  • Argos VCU: Google's custom silicon, 2x-33x encoding speed vs commodity
  • Vitess (born at YouTube ~2010): now runs at Slack, GitHub, HubSpot, Etsy

Interview soundbite: "YouTube is 500 hours uploaded per minute times a recommendation engine that decides which 20 clips YOU see next. Storage is trivially exabyte-scale; the interesting problem is (a) transcoding at $/hour scale — hence Argos silicon — and (b) two-tower ML ranking a billion candidates in <200ms. Vitess was invented here because MySQL didn't scale to the read load."

The whole journey at a glance

Every 10× in upload rate shifts the bottleneck:

text
═══════════ YOUTUBE ARCHITECTURE ACROSS 4 SCALES ═══════════ L4 (10 upl/day) L5 (1M upl/day) L6 (100M upl/day) L7 (720M+ upl/day, 2.7B MAU) S3 + CloudFront Multi-region + rec Vitess + rec Argos VCU + DNN ranker 12 weeks · $50K/mo 12 months · $2M/mo 24 months · $200M/mo ongoing · $10B/yr ┌────────┐ ┌────────┐ ┌── Global Cloudflare ┐ ┌── Google Edge PoPs ──┐ │ Web │ │ Web │ │ or CloudFront │ │ 1000+ PoPs · 200PB │ │TV/mob │ │TV/mob │ └─┬──┬──┬──┬─────────┘ │ own network + ISPs │ └───┬────┘ └───┬────┘ │ │ │ │ └──┬──┬──┬──┬──────────┘ │ │ ┌──▼──▼──▼──▼─────┐ │ │ │ │ ┌──▼───┐ ┌──▼──┐ │ Regional ALB │ ┌───▼──▼──▼──▼──────────┐ │ ALB │ │ ALB │ │ API tier │ │ Google Front End │ │ │ │ │ └───┬──────┬──────┘ │ (GFE) reverse-proxy │ └──┬───┘ └──┬──┘ │ │ │ + Envoy at internal │ │ │ │ │ └──┬──┬──┬──┬──────────┘ ┌──▼──────┐ ┌───▼─────────┐ ┌───▼──────▼───┐ │ │ │ │ │ Monolith│ │ Microserv. │ │ Playback svc │ ┌──▼──▼──▼──▼──────────┐ │ Django │ │ Go + Python │ │ Upload svc │ │ Playback / Upload / │ │ + MySQL │ │ + MySQL │ │ Rec svc │ │ Rec / Comment / Search│ │ + Redis │ │ + Vitess │ │ Search svc │ │ / Shorts / Ad tiers │ └──┬──────┘ └───┬─────────┘ │ Ad svc │ └──┬──┬──┬──┬──────────┘ │ │ └───┬───────────┘ │ │ │ │ │ ┌───▼──┐ ┌───▼──────────┐ ┌──▼──▼──▼──▼──────────┐ │ │Redis │ │ Vitess shards│ │ Vitess (many │ │ │thumbs│ │ (mySQL under)│ │ thousands of shards) │ │ └───┬──┘ └───┬──────────┘ └──┬───────────────────┘ │ │ │ │ ┌──▼───┐ ┌───▼─┐ ┌───▼──────────┐ ┌──▼─────────────────┐ │MySQL │ │MySQL│ │Sharded MySQL │ │ Two-tower deep NN │ │(vid │ │+ 3 │ │+ Vitess proxy│ │ candidate gen + │ │meta+ │ │repl │ │Covington 2016│ │ ranker (Covington │ │ user)│ │icas │ │DNN ranker │ │ 2016 + updates) │ └──────┘ └─────┘ │Spanner for │ │ 720M hours/day │ │ ads billing │ └────────────────────┘ └───┬──────────┘ │ │ ┌────▼──────────────┐ │ │ Argos VCU custom │ ┌───▼──────────┐ │ silicon for │ │Google Cloud │ │ transcoding │ │Storage + CDN │ │ 2x-33x commodity │ │(GCS multi- │ │ CPU speed │ │region) │ └──┬────────────────┘ └──────────────┘ │ ┌──▼──────────────┐ │ Spanner for ads │ │ + billing + │ │ strong-consist. │ │ paid features │ └─────────────────┘ ↑ ↑ ↑ ↑ Boring Vitess enters (YT Argos VCU custom silicon Two-tower deep NN + Django + MySQL invented it 2010 to for encoding. Recommend Argos + Spanner ads + works. handle read load). DNN goes live (Covington 200 PB edge cache + Async transcode. 2016 paper). 1000+ PoPs. Chapter 5 Chapters 6+6.5 Chapter 7+7.5 Chapter 8 walks walks through Vitess walks through Argos VCU walks through 2.7B MAU, through + async transcode + + Covington 2016 DNN Vitess-at-scale, L4 MVP Redis thumbnails ranker + Spanner ads Shorts vs long-form Key insight: YouTube is not "video storage" — it's transcoding at exabyte scale (hence Argos custom silicon) + ranking at billion-candidate scale (hence Covington 2016 two-tower DNN). Vitess was invented here because MySQL couldn't handle the read load. Every YouTube-scale problem has spawned an industry-wide tool.

The same 4 tiers as clean architecture diagrams

L4 · 10 uploads/day · Django + S3 + CloudFront · $50K/mo · 12 weeks:

flowchart TD W([Web / TV / Mobile]) -->|HLS| CF[CloudFront CDN<br/>$30K/mo egress] W -->|upload/API| API[Django monolith<br/>c5.large] API --> MY[(MySQL Multi-AZ<br/>videos + users + comments)] API -->|presigned PUT| S3[(S3<br/>video + thumbnails)] S3 -.->|origin fetch| CF API --> TR[Async Transcode workers<br/>FFmpeg on EC2] TR --> S3 classDef n fill:#dbeafe,stroke:#2563eb,color:#1e3a8a class CF,API,MY,S3,TR n

L5 · 1M uploads/day · Vitess + async transcode + rec service · $2M/mo · 12 months:

flowchart TD W([Global users]) -->|HLS| CF[CloudFront regional<br/>us-east · eu-west · ap] W --> API[100+ microservices<br/>Go + Python] API --> VT[(Vitess proxy<br/>+ Sharded MySQL<br/>videos + users + views)] API --> RS[Recommendation service<br/>collaborative filtering] RS --> VT API --> RD[(Redis cluster<br/>thumbnails + hot metadata)] API --> S3[(GCS multi-region<br/>video + thumbnails)] S3 -.->|origin fetch| CF API --> TR[Async Transcode workers<br/>FFmpeg on GPU/CPU] classDef n fill:#dbeafe,stroke:#2563eb,color:#1e3a8a classDef m fill:#fef3c7,stroke:#d97706,color:#78350f class CF,API n class VT,RS,RD,S3,TR m

L6 · 100M uploads/day · Argos VCU + Covington 2016 DNN · $200M/mo · 24 months:

flowchart TD W([Global users]) -->|HLS| CDN[Google Cloud CDN<br/>Regional PoPs] W --> API[Regional services] API --> VT[(Vitess many shards)] API --> DNN[Two-tower DNN ranker<br/>Covington 2016<br/>candidate gen + ranker] DNN --> VT DNN --> ES[Feature store<br/>Bigtable + Feast-like] API --> S3[(GCS<br/>videos + thumbnails)] S3 -.->|origin fetch| CDN API --> ARG[Argos VCU cluster<br/>custom silicon<br/>2x-33x encoding speed] ARG --> S3 API --> SP[(Spanner<br/>ads billing<br/>strong consistency)] classDef n fill:#dbeafe,stroke:#2563eb,color:#1e3a8a classDef m fill:#fef3c7,stroke:#d97706,color:#78350f classDef s fill:#dcfce7,stroke:#16a34a,color:#14532d class CDN,API n class VT,ES,S3,SP,DNN m class ARG s

L7 · 2.7B MAU · 720M hrs/day · Argos + Vitess + Spanner · $10B/yr:

flowchart TD W([2.7B users]) -->|HLS| GFE[Google Edge PoPs<br/>1000+ · 200 PB cache<br/>own backbone + ISP peering] W -->|control plane| GFE2[Google Front End GFE<br/>reverse-proxy + Envoy] GFE2 --> API[Playback / Upload / Rec /<br/>Comment / Search /<br/>Shorts / Ad tiers] API --> VT[(Vitess<br/>many thousand shards<br/>MySQL underneath)] API --> DNN[Two-tower deep NN<br/>Covington 2016 + updates<br/>720M hrs/day watch time] API --> ARG[Argos VCU custom silicon<br/>transcoding · 500hr/min uploaded<br/>Google Cloud blog 2021] API --> SP[(Spanner<br/>ads · billing · YT Premium<br/>strong consistency)] API --> BT[(Bigtable<br/>analytics · watch history<br/>hot feature store)] API --> GCS[(GCS multi-region<br/>10+ exabytes of video)] classDef n fill:#dbeafe,stroke:#2563eb,color:#1e3a8a classDef m fill:#fef3c7,stroke:#d97706,color:#78350f classDef s fill:#dcfce7,stroke:#16a34a,color:#14532d class GFE,GFE2,API n class VT,SP,BT,GCS,DNN m class ARG s

Why every 10× breaks the architecture

  1. Transcoding cost is the whole game at scale. L4 = FFmpeg on EC2 works. L6+ = you need custom silicon because commodity CPUs are 33x slower and $/hour math breaks. That's the Argos VCU story (Google Cloud blog 2021).
  1. Recommendation isn't a feature — it IS the product. 720M hours watched per day is not because users self-select; it's because the two-tower deep NN ranks a billion candidate videos per user, choosing 20. Reference: Covington et al. 2016 — the canonical paper every ML engineer reads.
  1. Vitess is the origin story you must cite. YouTube built Vitess ~2010 because MySQL didn't scale to their read load. Since then, Vitess runs at Slack, GitHub, HubSpot, Etsy. Do NOT say "YouTube uses MongoDB" or "Cassandra" — that's a common tutorial mistake.

The 3 senior insights before we start Chapter 1

  1. Custom silicon (Argos VCU) is a strategic moat. Amazon has Graviton, Google has TPU + Argos VCU + custom video ASIC. If your interview answer to "how do you handle 500 hours/minute of transcoding?" is "we scale FFmpeg horizontally", you're 2x-33x more expensive than YouTube. Naming Argos signals senior-level awareness. Reference: Argos VCU Google Cloud blog.
  1. Covington 2016 IS the recommendation architecture. The two-tower model (user tower + item tower → dot product) is the canonical setup. Candidate generation (fast, retrieves top 1000 from 10B) → ranker (slow, scores 1000, picks 20). Almost every consumer-scale rec system runs on this shape. Reference: Deep Neural Networks for YouTube Recommendations.
  1. Vitess started at YouTube. In 2010. To handle MySQL read load. Then it was open-sourced and became the sharding proxy of choice for Slack, GitHub, HubSpot, Etsy. YouTube's problems are precursors to industry-wide tools. If you're asked "how do you shard MySQL?", the answer is "Vitess — invented at YouTube, now runs half the internet."

Chapter map for the journey ahead

  • Chapter 1 — Requirements (upload, playback, comments, likes, recs, ads)
  • Chapter 2 — Capacity estimation (2.7B MAU, 500hr/min upload, 720M hrs/day watch)
  • Chapter 3 — API design (upload, playback, engagement, subscription)
  • Chapter 4 — Data model (videos, users, watch history, comments)
  • Chapter 4.5 — The Vitess origin: why YouTube invented it
  • Chapter 5 — L4 MVP: Django + S3 + CloudFront. Works up to 10K users
  • Chapter 6 — L5: Vitess + async FFmpeg transcode + recommendation service
  • Chapter 6.5 — Two-tower deep NN ranker (Covington 2016 in depth)
  • Chapter 7 — L6: Argos VCU custom silicon + Spanner ads billing
  • Chapter 7.5 — The transcoding cost model: $/hour math for FFmpeg vs Argos
  • Chapter 8 — L7: 2.7B MAU + Shorts + AI-generated content moderation
  • Chapter 9 — Failure modes: viral upload thundering herd, rec model degradation, ad brand safety
  • Chapter 10 — Trade-off matrix (YouTube vs TikTok vs Twitch)
  • Chapter 11 — Interview masterclass: 45-min mock, questions to ask
  • Chapter 12 — Defense: the 20 hardest interview questions on YouTube

Ready? Chapter 1 next: what did the CTO actually ask for?

Key takeaway

YouTube at 2.7B MAU is transcoding at exabyte scale + ranking at billion-candidate scale. Custom silicon (Argos VCU, 2x-33x commodity CPU) solved the transcoding cost problem. Two-tower deep NN (Covington 2016) solved the ranking problem. Vitess (invented at YouTube ~2010, now runs at Slack/GitHub/HubSpot) solved the MySQL read-load problem. Naming these three references signals senior-level awareness.

You should now be able to answer
  • Why does YouTube need custom silicon (Argos VCU) for transcoding?
  • What is the Covington 2016 two-tower deep NN model?
  • Why did YouTube invent Vitess and who else uses it today?
  • What does 500 hours uploaded per minute mean for storage + compute?
  • Why is Netflix's push-at-3am algorithm not applicable to UGC video?
Concept deep-dives referenced in this chapter

Every concept below has its own interactive, animated page in the Learning Tracks section. Read them any time you want to go deeper than the mentor prose above — they're the reusable foundation this chapter is built on.

Coming next

Chapter 1 next: what did the CTO actually ask for? Upload, playback, recs, comments, ads — each has functional and non-functional requirements per level. Get these wrong and you'll design the wrong system for the whole 12 chapters.

Components used in this design

Study each component's deep dive to understand it in isolation.

Load Balancer
load-balancer

Distributes incoming traffic across a pool of servers for scale and fault tolerance.

CDN (Content Delivery Network)
cdn

A globally distributed cache that serves static and cacheable dynamic content close to the user.

Redis
cache

An in-memory key-value store used for caching, pub/sub, rate limiting, distributed locks, and simple queues.

SQL Database
sql-db

A row-oriented, ACID-compliant relational database — the default for transactional workloads.

Kafka
stream

A distributed, partitioned, replicated commit log for event streaming, high-throughput ingest, and decoupled services.

API Gateway
api-gateway

Single entry point that handles auth, rate limiting, routing, and protocol translation for downstream services.

Object Storage (S3, GCS, Azure Blob)
object-storage

Durable, cheap, flat-namespace storage for blobs — images, videos, backups, logs, and any large binary object.

Search Engine (Elasticsearch, OpenSearch, Meilisearch)
search

Inverted-index-based full-text and structured search — the right tool for 'find me records matching this query' when SQL LIKE isn't fast enough.

Message Queue
queue

Async task queue that decouples producers from consumers and smooths bursts. Each message is processed exactly once (per-message ACK model).

Scheduler (cron, Airflow, Temporal timers)
scheduler

Runs jobs at a time or interval — the simplest form of eventual asynchronous computation.

Distributed Database (DynamoDB, Cassandra, Spanner)
nosql-db

Horizontally-scaled database with automatic partitioning and replication — the answer when one node can't hold the data or the traffic.

Patterns applied in this design

Study each pattern's deep dive for the recurring solution logic.

Explore next — related systems

If you enjoyed this problem, these share similar patterns or challenges.