01

Requirements & scope

Problem Statement & Requirements

Functional Requirements

  • Upload videos -- creators upload video files (up to 10 GB), system processes and stores them
  • Stream videos -- viewers watch videos with smooth playback, adaptive quality
  • Search & discovery -- search by title/tags, homepage recommendations, trending
  • Video metadata -- title, description, tags, thumbnails, view count, likes/dislikes
  • Comments -- threaded comments on videos
  • Subscriptions / channels -- users subscribe to creators, see new uploads in feed
  • Watch history & resume -- track progress, resume from where user left off
  • Live streaming (brief mention) -- real-time broadcast with minimal delay

Non-Functional Requirements

  • Low startup latency -- video begins playing within 2 seconds
  • No buffering -- adaptive bitrate prevents rebuffering on bandwidth changes
  • High availability -- 99.99% uptime for playback (upload can tolerate brief outages)
  • Global reach -- low latency worldwide via CDN
  • Scalability -- 1B+ DAU, 500+ hours of video uploaded per minute
  • Cost efficiency -- storage and bandwidth are the dominant costs

Out of Scope

  • Monetization / ads system (that's a separate design)
  • Creator analytics dashboard
  • Copyright detection (Content ID) -- mentioned briefly
  • Short-form video (TikTok-style) -- similar but different optimization profile
02

Scale estimations

Scale Estimations

Users & Content

MetricValue
Daily Active Users (DAU)1B
Total videos1B
New video uploads / day500 hours/min x 60 x 24 = 720,000 hours/day
Videos uploaded / day~5M (avg 8.6 min each)
Average video length8 minutes
Average views per user per day5 videos
Total video views / day5B

Storage

MetricValue
Raw video avg size (1080p, 8 min)~1.5 GB
Raw uploads / day5M x 1.5 GB = ~7.5 PB/day
Transcoded versions per video5 resolutions x 3 codecs = ~15 versions
Avg transcoded size (all versions)~3 GB total per video
Transcoded storage / day5M x 3 GB = ~15 PB/day
Total storage (accumulated)~exabytes
Thumbnail storage / day5M x 5 thumbs x 50 KB = ~1.25 TB

Bandwidth

MetricValue
Avg video bitrate (mixed quality)5 Mbps
Concurrent viewers (peak)~200M
Peak egress bandwidth200M x 5 Mbps = ~1 Petabit/s
Daily egress~500 PB/day

Transcoding

MetricValue
Videos to transcode / day5M
Transcoding time per video (1080p, 8 min)~30 min per resolution
Total compute needed5M x 15 versions x 30 min = enormous
Transcoding cluster size10,000+ machines
03

Layered architecture

Phase 1 of 4 · Client & edge

Start with the entry points

First, define who uses the system and where requests enter. This is the boundary of the design, not yet a complete request path.

Creator client
Upload large files in resumable chunks instead of sending video through an application server.
Upload service
Authorize uploads and create a durable video record before starting the processing pipeline.
Player
Choose a rendition using buffer health and measured throughput, then adapt during playback.
Architecture after phase 1. Includes Creator client, Upload service, Player. Creator client connects to Upload service.
Phase 1 — Start with Creator client, Upload service, Player.SVGSVGEditable diagramEditable diagram

This first layer defines the system boundary. The next chapters add application logic and data dependencies. After examining the request paths and tradeoffs, we will add operational safeguards and bring the complete architecture together.

04

API & contracts

Phase 2 of 4 · Application & compute

Add the application logic

Keep the entry points and add the services that do the work. Give each service a clear responsibility before defining its contracts. Storage and background dependencies come next.

Transcode workers
Create a ladder of renditions asynchronously; isolate failed transcode jobs for retry.
Video service
Expose playable manifests only after required outputs are ready.
Architecture after phase 2. Includes Creator client, Upload service, Transcode workers, Video service, Player. Creator client connects to Upload service. Player connects to Video service.
Phase 2 — Added Transcode workers, Video service. Earlier layers remain in place.SVGSVGEditable diagramEditable diagram

Creating an upload should return an upload ID and a resumable transfer contract. Playback needs a different contract: authorization, a manifest, and URLs for the available segments. A client polling processing status must be able to distinguish uploading, processing, ready, and failed instead of guessing readiness from the presence of an object.

05

Data model

Phase 3 of 4 · Data & async work

Connect data and background work

The services now need their dependencies: durable state, fast lookups, or work that continues outside a request. Separate these responsibilities rather than treating every component as a database.

Object storage
Store immutable media segments separately from video metadata.
CDN
Serve popular segments near viewers and shield the origin from repeated cache misses.
Architecture after phase 3. Includes Creator client, Upload service, Transcode workers, Video service, Object storage, CDN, Player. Creator client connects to Upload service. Upload service connects to Object storage. Object storage connects to Transcode workers. Transcode workers connects to Object storage. Video service connects to Object storage. CDN connects to Object storage. Player connects to Video service. Player connects to CDN.
Phase 3 — Added Object storage, CDN. Earlier layers remain in place.SVGSVGEditable diagramEditable diagram

Data Model

Video Metadata (MySQL / Vitess)

Video Metadata (MySQL / Vitess)
Video Metadata (MySQL / Vitess)SVGSVGEditable diagramEditable diagram

View Counts at Scale

View Counts at Scale
View Counts at ScaleSVGSVGEditable diagramEditable diagram
06

Core design decisions

Do not make viewers wait for the original video to finish every processing task. Define which renditions are sufficient for initial playback and publish a manifest only when its referenced segments are available. Adaptive playback chooses among prepared renditions; it does not ask the origin to re-encode each segment for each viewer.

07

Request flows

Video Upload Flow

Video Upload Flow
Video Upload FlowWide diagram — scroll horizontally.SVGSVGEditable diagramEditable diagram

Multipart Upload for Large Files

Multipart Upload for Large Files
Multipart Upload for Large FilesSVGSVGEditable diagramEditable diagram

Transcoding Pipeline -- The Heart of the System

Why Transcode?

Why Transcode?
Why Transcode?SVGSVGEditable diagramEditable diagram

Transcoding Output Matrix

Transcoding Output Matrix
Transcoding Output MatrixSVGSVGEditable diagramEditable diagram

Transcoding Architecture

Transcoding Architecture
Transcoding ArchitectureWide diagram — scroll horizontally.SVGSVGEditable diagramEditable diagram

Parallel Transcoding Strategy

Parallel Transcoding Strategy
Parallel Transcoding StrategySVGSVGEditable diagramEditable diagram

Video Playback Flow

Video Playback Flow
Video Playback FlowWide diagram — scroll horizontally.SVGSVGEditable diagramEditable diagram
08

Performance & caching

Cost Optimization

Cost Optimization
Cost OptimizationSVGSVGEditable diagramEditable diagram
09

Advanced design

Adaptive Bitrate Streaming (ABR)

How ABR Works

How ABR Works
How ABR WorksSVGSVGEditable diagramEditable diagram

HLS Manifest Example

HLS Manifest Example
HLS Manifest ExampleSVGSVGEditable diagramEditable diagram

ABR Algorithm (Client-Side)

ABR Algorithm (Client-Side)
ABR Algorithm (Client-Side)SVGSVGEditable diagramEditable diagram

CDN Architecture

Multi-Tier CDN Strategy

Multi-Tier CDN Strategy
Multi-Tier CDN StrategySVGSVGEditable diagramEditable diagram

CDN Content Routing

CDN Content Routing
CDN Content RoutingSVGSVGEditable diagramEditable diagram

Video Player Architecture

Video Player Architecture
Video Player ArchitectureSVGSVGEditable diagramEditable diagram

Recommendation Engine (Brief)

Recommendation Engine (Brief)
Recommendation Engine (Brief)SVGSVGEditable diagramEditable diagram

Live Streaming (Brief Overview)

Live Streaming (Brief Overview)
Live Streaming (Brief Overview)SVGSVGEditable diagramEditable diagram

Content Moderation & Copyright

Content Moderation & Copyright
Content Moderation & CopyrightSVGSVGEditable diagramEditable diagram
10

Edge cases

A creator may delete a video while cached segments remain at the edge. Decide how authorization expiry and cache invalidation limit continued access. Also handle partial processing failure: a broken high-resolution rendition need not make healthy lower-resolution versions disappear, but the manifest must not advertise missing segments.

11

Tradeoffs

Tradeoffs & Design Decisions Summary

DecisionOption AOption BChosenWhy
UploadThrough API serverDirect to S3 (presigned URL)Direct S3Avoids bottleneck; API servers don't handle GB-sized files
TranscodingSingle machine per videoParallel segment encodingParallel1-hour video: 5 min vs 2 hours
Streaming protocolProgressive downloadHLS / DASH (ABR)HLS/DASHAdaptive quality; works on all devices; industry standard
Segment duration2 seconds6 seconds6 secondsShorter = more requests + overhead; longer = coarser ABR switching. 6s is the industry sweet spot
CodecH.264 onlyH.264 + VP9 + AV1All threeH.264 for compatibility; VP9/AV1 for bandwidth savings on modern devices
CDNThird-party (Akamai)Own CDN (Open Connect)Depends on scaleYouTube/Netflix: own CDN. Startups: third-party
View countsSync DB updateAsync Kafka -> Redis -> DBAsyncCan't do 58K writes/sec to one row; batch aggregation
StorageSingle tierHot/warm/cold tieringTiered80% of views on 5% of videos; cold storage saves 60%+ cost
Transcoding scopeAll resolutions immediatelyLazy (popular = more codecs)Lazy90% of videos never need 4K; saves 40% compute
ThumbnailsSingle auto-generatedMultiple + creator choiceMultipleAuto-generate 3 candidates; let creator pick or A/B test
Metadata DBNoSQLMySQL (Vitess sharded)MySQL/VitessRelational queries needed (joins for search, channels); Vitess scales MySQL horizontally
12

Reliability & fault tolerance

Phase 4 of 4 · Operations & resilience

Add operational safeguards

With the request paths and tradeoffs established, add the controls that help detect trouble and keep the system operating. The final diagram retains every layer introduced so far.

Playback telemetry
Optimize user-visible startup delay, buffering, and cost rather than raw throughput alone.
Architecture after phase 4. Includes Creator client, Upload service, Transcode workers, Video service, Object storage, CDN, Player, Playback telemetry. Creator client connects to Upload service. Upload service connects to Object storage. Object storage connects to Transcode workers. Transcode workers connects to Object storage. Video service connects to Object storage. CDN connects to Object storage. Player connects to Video service. Player connects to CDN. Player connects to Playback telemetry.
Phase 4 — Added Playback telemetry. Earlier layers remain in place.SVGSVGEditable diagramEditable diagram

Make transcoding jobs repeatable using stable input versions and deterministic output locations. A worker can crash after writing a segment but before reporting success. Validate existing output on retry, and publish readiness atomically enough that players never receive a manifest pointing to unfinished media.

13

Production architecture

High-Level Architecture

High-Level Architecture
High-Level ArchitectureSVGSVGEditable diagramEditable diagram

Detailed Architecture (Read vs Write Paths)

Detailed Architecture (Read vs Write Paths)
Detailed Architecture (Read vs Write Paths)SVGSVGEditable diagramEditable diagram

Production Architecture

Production Architecture
Production ArchitectureSVGSVGEditable diagramEditable diagram
14

Further exploration

Compare a recorded lecture with a live sports match. The lecture favors reuse and efficient delivery; the match adds an end-to-end freshness budget. Follow where latency accumulates—in capture, encoding, packaging, delivery, and the player’s buffer—before choosing which safety margin to reduce.

15

Interview playbook

Interview Tips

  1. Separate upload from playback -- These are completely different systems. "Let me design the write path (upload + transcode) first, then the read path (streaming)." This structures your answer clearly.

  2. Transcoding is the centerpiece -- Spend the most time here. Explain why you need multiple resolutions + codecs, parallel segment encoding, and the output matrix.

  3. ABR is what makes streaming work -- "The player dynamically switches quality based on bandwidth. This is why Netflix doesn't buffer on your phone even on a spotty connection." Draw the segment timeline with quality switches.

  4. CDN is critical for scale -- "1 Petabit/s of egress bandwidth. No origin server handles that. You need a multi-tier CDN with edge PoPs worldwide." Mention Netflix Open Connect if you know it.

  5. View counts are a distributed systems problem -- "5B views/day. You can't UPDATE a SQL row on every view. Buffer in Kafka, aggregate in Redis, flush to DB." This shows you think about practical bottlenecks.

  6. Presigned URLs for upload -- "The video file goes directly from client to S3. Our API servers never touch the bytes." Simple but important.

  7. Cost awareness differentiates senior candidates -- "Storage is the biggest cost. Tiered storage, lazy transcoding, and AV1 codec migration are how YouTube/Netflix keep costs manageable at exabyte scale."

  8. HLS manifest is worth showing -- Write out the master playlist. It's concrete, shows you know the actual protocol, and takes 30 seconds to draw.

  9. Don't forget startup latency -- "Start with lowest quality for the first 2 segments, then ramp up. This gives sub-2-second time-to-first-frame."

  10. Mention live streaming briefly -- "Live is similar but uses RTMP for ingest and LL-HLS for playback with 2-6 second segments. The key difference is real-time transcoding instead of batch."