Bird
Raised Fist0
HLDsystem_design~12 mins

Video recommendation system in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Video recommendation system

This system suggests videos to users based on their interests and past behavior. It must handle many users and videos, provide quick recommendations, and update suggestions as users watch more videos.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
+----------------+       +----------------+
| Recommendation  |<----->| User Behavior   |
| Service        |       | Service        |
+----------------+       +----------------+
        |                        |
        v                        v
+----------------+       +----------------+
| Video Metadata |       | Cache          |
| Database       |       +----------------+
+----------------+                |
        |                         v
        +----------------->+----------------+
                           | NoSQL Database |
                           | (User Profiles) |
                           +----------------+
Components
User
user
Person who requests video recommendations
Load Balancer
load_balancer
Distributes incoming user requests evenly to API Gateway instances
API Gateway
api_gateway
Receives user requests and routes them to appropriate services
Recommendation Service
service
Generates video recommendations based on user data and video metadata
User Behavior Service
service
Tracks and processes user watch history and interactions
Video Metadata Database
database
Stores information about videos such as titles, categories, and tags
Cache
cache
Stores frequently accessed recommendations to reduce latency
NoSQL Database
database
Stores user profiles and behavior data for fast access
Request Flow - 14 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayCache
CacheAPI Gateway
API GatewayRecommendation Service
Recommendation ServiceUser Behavior Service
User Behavior ServiceNoSQL Database
User Behavior ServiceRecommendation Service
Recommendation ServiceVideo Metadata Database
Video Metadata DatabaseRecommendation Service
Recommendation ServiceCache
Recommendation ServiceAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Cache
Impact:Recommendations requests take longer because cache misses cause direct database queries
Mitigation:System falls back to querying databases and services directly; cache is rebuilt asynchronously
Architecture Quiz - 3 Questions
Test your understanding
Which component first receives the user's recommendation request?
ALoad Balancer
BAPI Gateway
CRecommendation Service
DCache
Design Principle
This design uses caching to reduce latency and load on databases. It separates concerns by having dedicated services for user behavior and recommendations. Load balancing and API Gateway ensure scalability and proper routing. The system gracefully handles cache misses by falling back to database queries.