| Scale | Users | Data Volume | Traffic | System Changes |
|---|---|---|---|---|
| Small | 100 users | Few thousand videos, user profiles | Low QPS (~100 requests/sec) | Single app server, single DB instance, simple batch recommendations |
| Medium | 10K users | Millions of videos, user interactions | Moderate QPS (~10K requests/sec) | Multiple app servers, DB read replicas, caching layer, offline model training |
| Large | 1M users | Hundreds of millions of videos, rich user data | High QPS (~100K requests/sec) | Distributed databases, sharded user data, real-time streaming data pipelines, CDN for video delivery |
| Very Large | 100M users | Billions of videos and interactions | Very high QPS (~10M requests/sec) | Multi-region deployment, advanced sharding, multi-level caching, AI model serving clusters, global CDN, data archiving |
Video recommendation system in HLD - Scalability & System Analysis
Start learning this pattern below
Jump into concepts and practice - no test required
At small scale, the database is the first bottleneck because it must handle many read and write requests for user interactions and video metadata. As users grow, the recommendation model training and serving become bottlenecks due to heavy computation and data volume. At large scale, network bandwidth and data storage also become critical bottlenecks.
- Database: Use read replicas to handle read traffic, connection pooling, and eventually shard user and video data by user ID or video category.
- Caching: Cache popular recommendations and video metadata using Redis or Memcached to reduce DB load.
- Application Servers: Horizontally scale app servers behind load balancers to handle increased request volume.
- Model Training and Serving: Use distributed computing frameworks for offline training and deploy models on dedicated serving clusters with GPU acceleration.
- Data Pipelines: Implement real-time streaming pipelines (e.g., Kafka) for user activity ingestion and feature updates.
- Content Delivery: Use a global CDN to serve video content efficiently and reduce latency.
- Storage: Use distributed object storage for videos and archive old data to cheaper storage tiers.
- Requests per second: At 1M users, expect ~100K QPS for recommendations and video views.
- Storage: Videos require petabytes of storage; metadata and user data require terabytes to petabytes.
- Bandwidth: Video streaming consumes the most bandwidth; a 1 Gbps link can serve ~125 MB/s, so multiple CDN edge servers are needed.
- Compute: Model training requires GPU clusters; serving models requires CPU/GPU servers scaled horizontally.
Start by clarifying scale and requirements. Discuss data volume, traffic patterns, and latency needs. Identify the first bottleneck and propose targeted solutions. Explain trade-offs between consistency, latency, and cost. Use real numbers to justify scaling steps. Show understanding of caching, sharding, and distributed systems.
Your database handles 1000 QPS. Traffic grows 10x to 10,000 QPS. What do you do first?
Answer: Add read replicas and implement caching to reduce database load before considering sharding or more complex solutions.
Practice
Solution
Step 1: Understand the purpose of recommendation systems
Recommendation systems aim to suggest content that matches user preferences to keep them engaged.Step 2: Identify the main goal in video platforms
Personalizing video content helps users find videos they like, increasing engagement and satisfaction.Final Answer:
To personalize video content to increase user engagement -> Option DQuick Check:
Personalization = Engagement [OK]
- Confusing storage with recommendation
- Thinking compression is the main goal
- Assuming deletion is automatic
Solution
Step 1: Identify real-time needs in recommendations
Real-time recommendations require processing fresh user interactions quickly.Step 2: Match components to real-time processing
Data streaming and processing systems handle live data to update recommendations instantly.Final Answer:
Real-time data streaming and processing -> Option AQuick Check:
Real-time = Streaming & Processing [OK]
- Choosing batch processing for real-time needs
- Confusing transcoding with recommendation
- Ignoring dynamic data updates
Solution
Step 1: Understand real-time recommendation generation
Real-time generation means recommendations can change instantly based on new data.Step 2: Analyze watch history update frequency
Even if watch history updates hourly, real-time components can use streaming data to update recommendations immediately.Final Answer:
The new video immediately influences recommendations -> Option AQuick Check:
Real-time generation = Immediate update [OK]
- Assuming batch update controls recommendation timing
- Thinking system crashes on data conflict
- Believing recommendations are static
Solution
Step 1: Identify the symptom - outdated recommendations
Outdated videos suggest the system is not processing recent user actions timely.Step 2: Check real-time data pipeline status
If the real-time pipeline is broken or delayed, fresh user data won't update recommendations promptly.Final Answer:
Real-time data pipeline is broken or delayed -> Option BQuick Check:
Outdated = Pipeline delay [OK]
- Blaming user profile deletion
- Confusing metadata issues with recommendation freshness
- Assuming batch runs cause outdated data
Solution
Step 1: Understand scalability challenges
Millions of users require efficient computation and timely recommendations without overload.Step 2: Evaluate design options for freshness and cost
Hybrid systems use batch training for accuracy and real-time updates for freshness, balancing cost and performance.Final Answer:
Use a hybrid approach combining batch model training with real-time feature updates -> Option CQuick Check:
Hybrid approach = Freshness + Cost balance [OK]
- Relying only on batch causes stale data
- On-demand without caching is costly
- Monolithic DB limits scalability
