Intermediate LevelSystem Design & Architecture
How do you design a News Feed System (Push/Fan-out on Write vs Pull/Fan-out on Read)?
β Interview Prompt: Explain News Feed architecture, Fan-out on Write (Push) vs Fan-out on Read (Pull), hybrid celebrity handling, and feed ranking algorithms.
Designing a social media News Feed System (Facebook/Twitter):
2 Fan-out Strategies:
β’
Fan-out on Write (Push): When a user posts, the system pushes post IDs directly into every follower's feed cache in Redis. Fast reads ($O(1)$), but fails for celebrities with 50 million followers!
β’
Fan-out on Read (Pull): Followers fetch posts from followed accounts when opening the app. Fast writes, slow reads.
β’
Hybrid Approach: Use Fan-out on Write for regular users, and Fan-out on Read for celebrity accounts!
Code Implementation Example
markdown
Hybrid News Feed Fan-Out Architecture:
[User Post] ββ> [Fan-Out Worker]
βββ (Regular User) ββ> Push to Followers' Redis Feed Caches
βββ (Celebrity) ββ> Save to Celebrity Post DB (Pulled on Read)π‘Hybrid Fan-out strategy for social media News Feed systems.
π― Interview Key Takeaway
Use a hybrid fan-out model: push posts for regular users to Redis feed caches, and pull posts dynamically for high-follower celebrity accounts.
#System Design#News Feed#Fan-out#Caching#Intermediate
Back to all System Design & Architecture Questionsβ