System Design Arena

System Design: Video Streaming Platform (like YouTube)

Break the problem into upload, processing, delivery, and engagement-just like you would during a senior-level interview.

Functional RequirementsNon-Functional RequirementsAPI Endpoints

Case Study

Video Streaming Platform

Same conversation, diagrams, and wrap-up you expectโ€”now framed with clearer scaffolding and iconography.

Prompt

Build a user-generated video platform supporting hour-long uploads, adaptive streaming, moderation, and creator analytics at global scale.

Interview snapshot

  • โ€ข Topic: Video Streaming Platform
  • โ€ข Expected depth: 45 - 60 minutes
  • โ€ข Focus areas: APIs, scale estimation, resilient architecture
  • โ€ข Wrap-up: risk, monitoring, disaster recovery

Key takeaways

  • โ€ข Creators upload, edit metadata, set privacy, manage monetization.
  • โ€ข Upload success >99.9% across regions.
  • โ€ข POST /api/videos - returns signed upload URL + metadata record, enqueues processing job.

๐ŸŽ™๏ธ Interview mode

Practice this like a real interview

Don't read the answer first. Work the framework against the bare prompt, then compare against what the interviewer expected at each step.

๐ŸŽฏ Start guided practice (free)

Scorecard

What the interviewer is evaluating

Requirements7/10
Scale estimation9/10
API design5/10
Architecture9/10
Trade-offs8/10
Failure handling7/10

Staff-level signal

Does the candidate split the write path (upload โ†’ transcode โ†’ distribute) from the read path (CDN-served playback) and treat them as different systems with different budgets?

๐Ÿง  Staff engineer judgment

The database barely matters here. If you are debating SQL vs NoSQL for video metadata before you have drawn the transcoding pipeline, you are designing the wrong system.

Calibration

The common (bad) answer

User โ†’ API โ†’ Video Service โ†’ Storage
                โ†“
            Database

โŒ Why this scores poorly: Ignores the two facts that define video: files are huge (transcoding is a pipeline, not a call) and playback is 99.9% of traffic (the CDN IS the product).

โœ“ What a strong answer adds

  • Estimate storage per minute of upload across renditions โ€” the number justifies everything else.
  • Design upload as resumable chunks feeding an async transcoding DAG.
  • Serve playback from CDN with signed URLs; origin only on cache miss.
  • Adaptive bitrate (HLS/DASH) as the mechanism connecting transcoding to smooth playback.
  • Keep metadata (views, titles) in a separate, boring CRUD system.

Build it up

Step-by-Step Walkthrough

Video is a bytes problem wearing an app-server costume. The interview is won by separating three flows early โ€” upload, processing, delivery โ€” and letting each one scale on its own terms.

1

Naive: upload through the app server, serve the file back

One service, one endpoint. POST /api/videos streams the whole file through your web server onto attached storage; GET streams it back out. Metadata is a row in SQL. For a handful of videos this genuinely works.

Then say the sizes out loud: a single upload is ~200 MB, and a flaky mobile connection at minute nine of a ten-minute upload restarts from zero. Your web server is now a file-transfer proxy burning connections on multi-minute requests, and every viewer pulls the one original file at whatever bitrate their network can't sustain.

?Do the ingest math before drawing anything

On the order of ~500K uploads/day at ~200 MB each is ~100 TB/day of ingest โ€” ~300 TB/day after triple replication, before renditions. That single number justifies object storage, an async pipeline, and storage tiering in one breath.

2

Get the bytes off your servers: signed URLs + resumable chunks

The fix is to stop proxying bytes. POST /api/videos creates the metadata record and returns a signed URL; the client uploads directly to object storage (S3/GCS) in chunks, each retryable and idempotent under an uploadId. A dropped connection resumes at the last acknowledged chunk instead of restarting.

When the final chunk lands, storage emits a completion event onto an event bus. Your API tier never touched the video โ€” it only brokered permission. This is the upload contract interviewers want stated explicitly: signed URLs, chunking, idempotency, resume.

3

Processing is a DAG, not a function call

One file can't serve a phone on 3G and a TV on fiber. The completion event feeds Kafka; a fleet of transcoding workers fans each video out into ~6 renditions (multiple resolutions and bitrates), segments them for HLS/DASH, and writes results back to object storage before flipping the metadata row to available.

Renditions add roughly ~0.6x the original size โ€” on the order of another ~120 TB/day โ€” and peak load wants ~tens of thousands of concurrent transcode jobs, so the fleet autoscales on queue depth. Jobs must be idempotent: a worker that dies mid-encode gets its job redelivered, and re-running it must be safe.

!The retry question is coming

Interviewers will ask what happens when a transcode fails halfway. The answer is idempotent jobs keyed by (videoId, rendition) writing to deterministic paths โ€” retries overwrite, never duplicate. Without that, your storage fills with orphaned half-renditions.

4

Delivery: the CDN is the product

Playback is GET manifest.m3u8 โ†’ signed CDN URLs โ†’ the player adaptively picks renditions segment by segment. At ~5M concurrent viewers around ~3 Mbps, egress is on the order of ~15 Tbps โ€” your origin cannot serve that, so you need a >95% CDN offload rate, with an origin shield collapsing edge misses so storage sees one fetch per segment, not thousands.

Private and unlisted videos ride the same edge: tokens embedded in the signed segment URLs are validated at the POP, so authorization never adds an origin round trip. Playback start under ~2 s comes from the manifest listing a low-bitrate first segment the edge almost certainly has cached.

5

Engagement, analytics, and the moderation lane

Likes and comments are high-write, low-consistency data โ€” they go to a NoSQL store plus a search index, not the relational metadata DB. Watch events stream into the analytics lake, powering creator dashboards that are eventually consistent by design; nobody needs view counts accurate to the second.

Moderation is the lane candidates forget: an ML service scores every upload for risk during processing, flagged content routes to a human review tool that fetches assets via signed URLs, and copyright fingerprinting (Content ID-style) runs as one more consumer of the same processing events. Raising takedowns unprompted is a strong senior signal.

Blueprint

Architecture Diagram

The narrated components above, laid out as an actual flow โ€” so you can see how a request moves through the system, not just read a list of pieces.

Upload flow

1

client

2

upload gateway

3

signed URL (S3/GCS)

4

object storage

5

event bus

Processing

1

Kafka

2

transcoding workers

3

storage

4

metadata DB update

5

publish availability event

Delivery

1

CDN edges serve

CDN edges serve HLS/DASH

2

origin shield protects

origin shield protects storage

3

token-based auth for

token-based auth for private videos

Engagement

1

likes/comments in NoSQL + search index

2

watch events stream into analytics lake

Moderation

1

ML service labels risk

ML service labels risk, human review tool fetches assets via signed URLs

Flow Diagram

How the API maps to this flow

  1. 1POST /api/videosโ€” returns signed upload URL + metadata record, enqueues processing job.
  2. 2POST /api/videos/{id}/chunksโ€” resumable upload chunk endpoint (idempotent with uploadId).
  3. 3GET /api/videos/{id}/manifest.m3u8โ€” ABR manifest referencing signed CDN URLs.
  4. 4GET /api/videos/{id}/statsโ€” aggregated watch metrics.
  5. 5POST /api/videos/{id}/moderationโ€” flag video for review.

?But why does this actually hold up at scale?

500K uploads/day * 200 MB ~ 100 TB ingest; triple replication = 300 TB/day growth before tiering.

Video walkthrough

Design YouTube โ€” System Design Interview

NeetCode ยท 26 min

Upload pipeline, transcoding and CDN delivery, explained in the order an interviewer expects to hear them.

Work the prompt yourself first โ€” guided practice grades your own answer step by step. Watching someone else design it feels like progress and teaches you far less.

Interview flow

Dialogue timeline

Interviewer

State the core flows.

Candidate

Creators upload via signed URLs, videos get processed into multiple renditions, viewers stream via CDN, and engagement data feeds analytics and recommendations.

Interviewer

How do uploads stay reliable?

Candidate

Use resumable chunk uploads to object storage, with a control plane tracking state. Metadata writes go to SQL, and uploads emit events to kick off processing.

Interviewer

Processing pipeline?

Candidate

Kafka queue fans out to autoscaled transcoding workers (FFmpeg). Each worker writes renditions + thumbnails, updates metadata state machine, and publishes completion events.

Interviewer

Describe playback and analytics.

Candidate

CDN serves manifests and segments with token auth. Watch/like/comment events stream through Kafka -> Flink -> BigQuery for dashboards and recommender training.

Scoping

Requirements & trade-offs

Functional Requirements

  • โ€”Creators upload, edit metadata, set privacy, manage monetization.
  • โ€”Viewers search, subscribe, stream via adaptive bitrate, interact (likes/comments).
  • โ€”Real-time creator dashboards for views/watch time/RPM.
  • โ€”Moderation workflows for flags, copyright claims, takedowns.

Non-Functional Requirements

  • โ€”Upload success >99.9% across regions.
  • โ€”Playback start <2 s for 95th percentile viewers.
  • โ€”Storage durability 11 nines with multi-region replication.
  • โ€”Cost controls: cold storage tiering, autoscaled transcoding, CDN offload >95%.

Blueprint

Architecture modules

Module 1

API Endpoints

  • โ€ขPOST /api/videos - returns signed upload URL + metadata record, enqueues processing job.
  • โ€ขPOST /api/videos/{id}/chunks - resumable upload chunk endpoint (idempotent with uploadId).
  • โ€ขGET /api/videos/{id}/manifest.m3u8 - ABR manifest referencing signed CDN URLs.
  • โ€ขGET /api/videos/{id}/stats - aggregated watch metrics.
  • โ€ขPOST /api/videos/{id}/moderation - flag video for review.

Module 2

Back-of-the-Envelope

  • โ€ข500K uploads/day * 200 MB ~ 100 TB ingest; triple replication = 300 TB/day growth before tiering.
  • โ€ขEach video -> 6 renditions (~0.6x size) ~ 120 TB/day extra. Autoscale transcoding fleet to ~20K concurrent jobs peak.
  • โ€ข5M concurrent viewers @3 Mbps ~ 15 Tbps egress; CDN needed for 95% hit rate.
  • โ€ขMetadata DB: 500K rows/day * 2 KB ~ 1 GB/day; partition by upload date, archive after 1 year.

Module 3

System Diagram Notes

  • โ€ขUpload flow: client -> upload gateway -> signed URL (S3/GCS) -> object storage -> event bus.
  • โ€ขProcessing: Kafka -> transcoding workers -> storage -> metadata DB update -> publish availability event.
  • โ€ขDelivery: CDN edges serve HLS/DASH; origin shield protects storage; token-based auth for private videos.
  • โ€ขEngagement: likes/comments in NoSQL + search index; watch events stream into analytics lake.
  • โ€ขModeration: ML service labels risk, human review tool fetches assets via signed URLs.

Module 4

Design Playbook

  • โ€ขStart with upload contract, retries, signed URLs.
  • โ€ขExplain processing DAG and failure retries (idempotent jobs).
  • โ€ขDiscuss CDN strategy, cache keys, token auth.
  • โ€ขCover moderation + copyright (fingerprinting, DMCA).
  • โ€ขTalk monitoring: ingest latency, transcoding backlog, CDN cache hit ratio, analytics lag.
  • โ€ขEnd with DR: multi-region storage replication, config rollbacks, chaos tests on processing fleet.