A news feed shows each user recent posts from the accounts they follow. Users read their feed far more often than anyone posts, and some accounts have millions of followers. The core decision is when to do the work of matching posts to readers.
Numbers
| Quantity | Math | Result |
|---|---|---|
| Daily active users | 200M | |
| New posts | 200M × 1 per day ÷ 86,400 | ≈ 2,300/s |
| Feed loads | 200M × 10 per day ÷ 86,400 | ≈ 23,000/s |
| Feed inserts if every post is pushed | 2,300 × 200 average followers | ≈ 460,000/s |
Fan-out on write (push)
When someone posts, a worker looks up their followers and adds the post ID to each follower's precomputed feed, typically a capped Redis sorted set of the newest few hundred IDs. Reading a feed is then a single cheap lookup.
Where it breaks: a celebrity with 10 million followers creates 10 million feed writes per post, and each of those followers' feeds updates late. Most of that work is wasted on followers who won't open the app today. Deletes and edits have to be fanned out too.
Fan-out on read (pull)
Store only each author's own posts. When a user opens the feed, fetch recent posts from everyone they follow and merge them, a k-way merge by time or score.
Where it breaks: a user who follows 2,000 accounts triggers 2,000 lookups per feed load, at 23,000 loads per second. Reads become slow and expensive, and that's the operation users do most.
The hybrid most systems use
- Push for ordinary authors, who have hundreds or thousands of followers.
- Pull for celebrities above a threshold (say 100,000 followers). Their recent posts are cached hot, because millions of readers want the same few posts.
- At read time, merge the precomputed feed with recent posts from the celebrities that user follows.
- Skip pushing to inactive users, and build their feed on demand when they return.
That answers the celebrity question: a post by an account with 10M followers costs one write, plus a cache entry that millions of feed reads share.
Storage
- Posts: sharded by post ID or author ID. Feed caches hold only IDs, and posts are fetched in bulk (multi-get) from a post cache, so an edit updates one place.
- Follow graph: store both directions,
followers(author)for fan-out andfollowing(user)for pull, because each is queried by a different key. - Feed cache: keep only the last few hundred IDs per user. Older pages come from a slower path.
Ranking and pagination
Chronological feeds sort by time. Ranked feeds first gather candidates (pushed IDs plus pulled celebrity posts), then score them with a model and keep the best. Paginate with a cursor (the last ID or score seen), not an offset: new posts arriving at the top would make offset pages shift and repeat.
Interview checklist
- Estimate posts per second, feed reads per second and average followers.
- Explain push and pull, and where each breaks.
- Propose the hybrid with a celebrity threshold.
- Store IDs in feeds and fetch post bodies in bulk.
- Use cursor pagination, and say how ranking fits in.
Level 14: Fan-out
Put this into practice against live traffic. Your progress in the game is saved in your browser.
Play level 14Further reading
- Alex Xu, System Design Interview: An Insider's Guide, volumes 1 and 2. Worked case studies in interview format.
- Martin Kleppmann, Designing Data-Intensive Applications (O'Reilly). The standard book on replication, partitioning and consistency.
- Site Reliability Engineering, Google's free book on running reliable systems.
- The Amazon Builders' Library: practical articles on timeouts, retries, caching and load shedding.
- The System Design Primer: a broad, community-maintained overview.