Design a Social News Feed (Twitter / X)
Solving the Celebrity Fan-out problem with Hybrid Push (Fan-out on Write) + Pull (Fan-out on Read)
Difficulty: Advanced · Read time: 9 min · Access: Step-1 Preview + Knoera Pro
How It Works
Building a user’s home timeline naively by executing a SQL (Structured Query Language) `JOIN` across `follows` and `posts` at read time collapses under load. Fan-out on Write (Push) pre-computes followers’ Redis timeline lists the instant someone posts—making feed reads `O(1)` (constant time)—but triggers massive write amplification when celebrities with 50 million followers post. The production solution is Hybrid Fan-out: eager async Push for regular accounts and lazy Pull merging at read time for mega-accounts.
Why It Matters
Social graphs follow extreme power-law distributions where 99% of users have hundreds of followers and 0.01% have tens of millions; Hybrid Fan-out isolates celebrity write bursts while keeping p99 feed loads under 25 ms.
Interactive Architecture Scenarios
- Hybrid Push + Celebrity Pull Timeline
- Failure Mode: Pure Push Celebrity Write Storm