Design a News Feed
System Design Cases: lesson 4 of 20
Pay at write time, at read time, or a little of both.
Lesson 4 of 20 · 7 min
Design a News Feed
Step 1 of 11
Ten million users, 500 posts a second, and fifty reads for every write. The ratio decides everything.
The Idea
Show each user recent posts from the accounts they follow, ranked. Assume 10 million users, 500 posts a second, and fifty reads per write — the ratio decides whether you pay when a post is published or when a feed is opened.
Real-World Example
A delivery round versus a newsstand. Dropping a copy through every subscriber's door is fan-out on write; making everyone walk to the stand and pick their titles is fan-out on read.
The Tradeoff
Fan-out on write gives an O(1) read and turns a celebrity's single post into tens of millions of inbox writes. Fan-out on read publishes instantly and makes every open a large merge. Real systems split it: write for ordinary accounts, read for the few enormous ones.
Your turn
Put the steps in the right order.
- Merge the prebuilt inbox with freshly pulled celebrity posts
- Write the post once to the author's own timeline
- Rank the merged set and return one page
- Fan the post id into each ordinary follower's inbox
Mini quiz
1 / 3