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), each starting, say, five videos a day: 500 M playback starts a day, or about 5,800 per second on average (500 M / 86,400 ≈ 5,790), with peaks two to three times that. Each playback then fetches a stream of segments, so the CDN serves far more requests than that. Uploads are far fewer, 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 and auto-scaling; title and tag search goes to a search index such as OpenSearch fed from the table's change stream, because secondary indexes support key lookups and range queries, not full-text 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. A worker (a Lambda function or a small service) pulls the message and submits an AWS Elemental MediaConvert job (or runs FFmpeg on a self-managed EC2 fleet) that 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
| Entity | Primary Key | Important Attributes |
|---|---|---|
| Video | video_id (UUID) | s3_key, title, description, uploader_id, upload_timestamp |
| Metadata | video_id | thumbnail_s3_key, duration, tags |
| Likes | video_id#user_id (composite) | timestamp |
| Comments | video_id#comment_id | user_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.
- Chooses high-cardinality partition keys (video_id) so DynamoDB spreads load across partitions, adds global secondary indexes for access patterns such as videos by uploader, and puts title and tag search in a search index such as OpenSearch.
- 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: a CloudFront origin group fails over to a replica bucket in a second region when the primary S3 origin returns errors.
What a Staff Answer Includes
- Failure modes: S3 outage, CDN edge cache miss, MediaConvert job failure, DynamoDB throttling. Notes that S3 and DynamoDB already replicate across AZs within a region, and shows how S3 Cross-Region Replication and DynamoDB global tables survive a region loss.
- Operational tooling: Terraform or CDK for IaC, canary deployments via AWS CodeDeploy, and automated chaos testing with AWS Fault Injection Service.
- Cost analysis: Estimates the two big drivers: storage, billed per GB-month and multiplied by every rendition kept, and CDN egress, billed per GB delivered and usually the larger bill at scale. 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
| Mistake | Why It Hurts |
|---|---|
| Ignoring numbers | Without ball-park traffic you cannot justify scaling choices. |
| Skipping the CDN layer | Playback latency will be unrealistic; interviewers expect edge caching. |
| Over-engineering the encoding pipeline | A simple SQS + worker model is enough; adding Kafka without need shows poor scope control. |
| Forgetting failure handling | Real services must survive partial outages; not addressing it looks naive. |
| Mixing too many AWS services | Too many moving parts without clear rationale confuses the design. |
How to Practice This
- Read the free worked design, Design a Video Streaming Platform: start with the board for your level. It covers the same ground (multipart upload to S3, a MediaConvert job started on upload, HLS segments through CloudFront) with notes on each component, and differs in places, such as an ALB in front of the video API and, from the senior board on, ffmpeg workers on Spot instead of MediaConvert.
- Draw your own diagram on paper or a whiteboard, fill in the data model, and write a brief rubric for the junior, senior, and staff answers.
- Run a mock interview: present the design, answer follow-up questions, and check your diagram against your rubric for gaps. With Pro ($10/month), draw it on the practice canvas and have the Coach check it against the practice brief's rubric.
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, multiply by actions per user per day, divide by 86,400 seconds for the average rate, then apply a peak factor. For 100 M DAU starting, say, five videos each a day, that is about 5,800 playback starts a second on average (500 M / 86,400).
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.