System Design AI

Design a Video Streaming Service like YouTube: Junior, Senior, and Staff Answers

When an interviewer asks you to design a video-streaming service like YouTube, they are testing three things: your ability to break down a huge product into manageable pieces, your grasp of scalability patterns, and how you think about operations and trade-offs. The question is open-ended on purpose – they want to see how you prioritize, what assumptions you surface, and whether you can move from a high-level sketch to concrete AWS services.

Core Requirements and Driving Numbers

Functional

  • Upload video, store it, and make it available for on-demand playback.
  • Serve thumbnails and metadata (title, description, likes, comments).
  • Support basic search and recommendation APIs.
  • Provide a simple UI for playback, seeking, and adaptive bitrate.

Non-functional

  • Scalability: Assume 100 million daily active users (DAU). That is roughly 1 k requests per second for video playback (100 M / 86 400 ≈ 1 160 req/s) and far fewer uploads, because many more people watch than upload.
  • Latency: Video start-up should be under 2 seconds for 95 % of users.
  • Durability: All uploaded videos must be stored with 99.999999999 % durability.
  • Consistency: Metadata reads can be eventually consistent; uploads need strong consistency for the uploader.

These numbers drive the choice of storage, caching, and request routing.

Request Path – One Hop at a Time

1. Client → API Gateway

The client (web or mobile) sends a request to an Amazon API Gateway endpoint. API Gateway gives you throttling, auth (Cognito or IAM), and a clean entry point.

2. API Gateway → Application Service

API Gateway forwards the request to a AWS Lambda (for low-traffic paths) or an ECS/Fargate service (for heavier workloads). This layer performs authentication, request validation, and routing to the appropriate downstream component.

3. Service → Data Store

  • Metadata (title, tags, likes): Stored in Amazon DynamoDB. DynamoDB gives single-digit millisecond reads, auto-scaling, and easy secondary indexes for search.
  • User-generated data (comments): Also DynamoDB, partitioned by video-id + timestamp.

4. Service → Video Store

Uploaded files are written directly from the client to Amazon S3 using pre-signed URLs. The service records the S3 object key in DynamoDB.

5. Service → Encoding Pipeline

A SQS queue receives a message with the S3 key. An AWS Elemental MediaConvert worker (or a self-managed EC2 fleet) pulls the message, transcodes the video into multiple bitrates, and writes the renditions back to S3 under a predictable path.

6. Service → CDN

Amazon CloudFront is placed in front of the S3 bucket. CloudFront caches the most-watched renditions at edge locations, delivering sub-second latency for playback.

7. Playback Path

The client requests https://d111.cloudfront.net/video/12345/720p.m3u8. CloudFront checks its edge cache; a miss triggers an S3 fetch, which is then cached for subsequent viewers.

Data Model Snapshot

EntityPrimary KeyImportant Attributes
Videovideo_id (UUID)s3_key, title, description, uploader_id, upload_timestamp
Metadatavideo_idthumbnail_s3_key, duration, tags
Likesvideo_id#user_id (composite)timestamp
Commentsvideo_id#comment_iduser_id, text, timestamp

What a Junior Answer Covers

  • Lists the components above in a diagram.
  • Mentions S3 for storage, CloudFront for CDN, DynamoDB for metadata.
  • Provides the basic request flow.
  • Gives rough numbers (e.g., 100 M daily users) and mentions scaling via auto-scaling groups.
  • Shows a simple ER-style data model.
  • No discussion of async pipelines, cache invalidation, or operational concerns.

What a Senior Answer Adds

  • Introduces ElastiCache (Redis) for hot-video metadata and view-count counters to reduce DynamoDB read pressure.
  • Describes a write-behind cache pattern: after a watch, increment a Redis counter, flush to DynamoDB every N minutes.
  • Adds sharding of DynamoDB tables (by video_id hash) and global secondary indexes for search.
  • Discusses partitioned upload handling: multipart upload to S3, client-side chunking.
  • Mentions monitoring with CloudWatch metrics and alarms for latency spikes.
  • Explains a fallback path: if CloudFront edge is unavailable, the request falls back to S3 directly.

What a Staff Answer Includes

  • Failure modes: S3 outage, CDN edge cache miss, MediaConvert job failure, DynamoDB throttling. Shows how to use S3 Cross-Region Replication and multi-AZ DynamoDB to survive AZ loss.
  • Operational tooling: Terraform or CDK for IaC, canary deployments via AWS CodeDeploy, and automated chaos testing with AWS Fault Injection Simulator.
  • Cost analysis: Rough estimate of storage (e.g., 1 TB video ≈ $23/month in S3 Standard) and data transfer (100 TB out via CloudFront ≈ $8 K). Shows trade-off between higher bitrate renditions vs. bandwidth cost.
  • Defending a trade-off: Choosing MediaConvert over a custom FFmpeg farm because it reduces operational burden despite higher per-minute cost.
  • Observability: Distributed tracing with AWS X-Ray, logging to CloudWatch Logs, and alerting on 99th-percentile start-up latency.
  • Security: Signed URLs for upload, bucket policies restricting public read, and IAM roles for each microservice.

Common Mistakes That Sink the Interview

MistakeWhy It Hurts
Ignoring numbersWithout ball-park traffic you cannot justify scaling choices.
Skipping the CDN layerPlayback latency will be unrealistic; interviewers expect edge caching.
Over-engineering the encoding pipelineA simple SQS + worker model is enough; adding Kafka without need shows poor scope control.
Forgetting failure handlingReal services must survive partial outages; not addressing it looks naive.
Mixing too many AWS servicesToo many moving parts without clear rationale confuses the design.

How to Practice This

  1. Study the worked design in the System Design AI library. The walkthrough shows the same request path with notes on each component.
  2. Create your own canvas: draw the diagram, fill in the data model, and write a brief rubric for the junior, senior, and staff answers.
  3. Run a mock interview: present the design, answer follow-up questions, and have the AI coach review your canvas for gaps.

Questions people ask

What are the most important AWS services for a video streaming service?

S3 stores the raw and transcoded files, CloudFront caches them at the edge, DynamoDB holds metadata, ElastiCache speeds up hot reads, and SQS (or MSK) drives the async encoding pipeline.

How do you estimate the load for a service like YouTube?

Start with daily active users, divide by seconds in a day to get requests per second, then add a safety factor. For 100 M DAU you get roughly 1 200 req/s for playback.

Why use a CDN instead of serving video directly from S3?

A CDN reduces latency by caching content close to users and offloads traffic from S3, which saves cost and improves start-up time.

What is a common failure mode and its mitigation?

If the encoding worker fails, the SQS message can be retried or moved to a dead-letter queue. Using multiple workers across AZs ensures the pipeline stays alive.