π ππππ₯π’π§π ππ¨ ππ’π₯π₯π’π¨π§π¬: ππ¨π° ππ¨ πππ§ππ₯π ππ‘π βπππ¬π¬π’ ππππππβ π’π§ π πππ πππ¬π’π π§
As a backend developer, building a real-time feed like Facebook or X (Twitter) for billions of users isnβt just about speed β itβs about managing write amplification.
When a user posts, how do their friends see it in milliseconds? Most systems use a Fan-out (Push) approach:
The Workflow: When you post, the system βpushesβ that post ID into the pre-computed feeds (usually in Redis/Memcached) of all your followers.
The Benefit: Reading your feed is lightning-fast because itβs already built.
The Bottleneck: This works for me and you. But what happens when Lionel Messi posts to his 500M+ followers?
Get Jubair Abdullahβs stories inΒ yourΒ inbox
Join Medium for free to get updates fromΒ thisΒ writer.
β οΈ The Celebrity Problem
If we use a pure Fan-out/Push model for a celebrity, a single post triggers 500 million write operations to different caches instantly. This causes massive βhotkeyβ issues, cache invalidation storms, and can easily crash your database clusters.
π‘ The Solution: The Hybrid Approach
To keep the system smooth, we treat βCelebritiesβ and βNormal Usersβ differently:
For Normal Users (Push): We continue using the Fan-out model. The scale is manageable, and it keeps read latency low for the average user.
For Celebrities (Pull): We stop pushing their posts to followersβ caches. Instead, when a follower logs in or refreshes their feed, the system βpullsβ the celebrityβs recent posts and merges them into the userβs feed on the fly.
The Result: We trade a tiny bit of read latency for the follower to save the entire infrastructure from a write-heavy meltdown.
π οΈ Key Takeaway
Architecture isnβt about finding one βperfectβ tool; itβs about identifying different traffic patterns and applying the right strategy to each.
How would you handle the βCelebrityβ notification problem? Letβs discuss in the comments! π
hashtag#SystemDesign hashtag#BackendEngineering hashtag#Scalability hashtag#Redis hashtag#SoftwareArchitecture hashtag#TechCommunity






