Bird
Raised Fist0
HLDsystem_design~12 mins

News feed generation in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - News feed generation

This system generates personalized news feeds for users by collecting posts from their connections and relevant sources. It must deliver fresh content quickly and handle many users simultaneously.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Feed Service <--> Cache
  |
  v
Database
  |
  v
Message Queue
  |
  v
Feed Generator Service
  |
  v
Content Sources
Components
User
client
Requests personalized news feed
Load Balancer
load_balancer
Distributes incoming user requests evenly to API Gateway instances
API Gateway
api_gateway
Handles authentication, routing, and request validation
Feed Service
service
Serves news feed data to users, checks cache before database
Cache
cache
Stores recently generated feeds for fast retrieval
Database
database
Stores user data, posts, and feed metadata
Message Queue
queue
Queues feed generation tasks asynchronously
Feed Generator Service
service
Processes queued tasks to generate and update user feeds
Content Sources
external_service
Provides new posts and updates from users and publishers
Request Flow - 12 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayFeed Service
Feed ServiceCache
CacheFeed Service
Feed ServiceDatabase
DatabaseFeed Service
Feed ServiceUser
Content SourcesFeed Generator Service
Feed Generator ServiceMessage Queue
Feed Generator ServiceDatabase
Feed Generator ServiceCache
Failure Scenario
Component Fails:Cache
Impact:Feed Service cannot retrieve cached feeds, causing increased database load and slower response times
Mitigation:System falls back to database queries for feeds; cache is rebuilt asynchronously by Feed Generator Service
Architecture Quiz - 3 Questions
Test your understanding
Which component handles user authentication and routes requests to services?
ALoad Balancer
BFeed Service
CAPI Gateway
DMessage Queue
Design Principle
This design uses caching to speed up feed retrieval and asynchronous processing with message queues to handle feed updates efficiently. It separates user request handling from feed generation to improve scalability and responsiveness.