CHAPTER 15
Design a News Feed
Fan-out on write vs read, the celebrity problem and ranking
Source: PDF p. 52
Core PDF content
| Functional requirements | Non-functional requirements and scale |
|---|---|
| - Publish posts (text, media) - Follow / unfollow users - View a personalised home feed, scrolling with pagination - Likes and comments (counts shown on posts) | - Feed load p99 < 300 ms - Highly available; eventual consistency of feeds is fine (seconds) - 200 M DAU, ~5 feed opens per user per day, avg 200 followers, some accounts with 50 M followers |
| Quantity | Estimate | Design implication |
|---|---|---|
| Feed reads | 200 M x 5 = 1 B/day = ~11,500/s (peak ~35,000) | Read-heavy: precompute and cache |
| Posts | 50 M/day = ~580/s | Writes are modest |
| Fan-out writes (push) | 50 M x 200 followers = 10 B/day = ~115,000/s | Large but async; needs a queue and sharded cache |
| Feed cache | 200 M users x 800 post IDs x 8 B = ~1.3 TB | Store IDs only, in Redis across a cluster |
| Celebrity post | 1 post x 50 M followers | Pushing 50 M inserts per post is infeasible: use pull |
Deep dive: push, pull or hybrid p. 52
| Fan-out on write (push) | Fan-out on read (pull) | Hybrid (what large systems do) | |
|---|---|---|---|
| Feed read | Fast: read a precomputed list | Slow: query all followees' posts and merge | Fast list + merge a few celebrity timelines |
| Post write | Expensive for users with many followers | Cheap: store once | Push for normal users; skip celebrities |
| Storage | Duplicates IDs per follower | Minimal | Moderate |
| Problems | Celebrity storms, wasted work for inactive users | Latency spikes, heavy read load | More moving parts |
- Ranking: candidate generation (recent posts from graph + recommended) followed by an ML ranker predicting engagement (like/comment/share/dwell) from features (author affinity, recency, post type, user history); then diversity and policy filters (Ch. 28).
- Pagination: cursor = (score, post_id) so new posts do not shift pages. Cache the first page aggressively.
- Counters (likes, views): very hot rows. Use sharded counters in Redis, async aggregation, and show approximate counts.
- Media: upload to object storage, transcode, serve from CDN; the feed only carries URLs.
Review questions for this chapter have not been written and reviewed yet. The chapter text above is the full source content.
Try it
References
System Design & AI System Design: The Complete Guide — 2026 Edition, p. 52; figures 36.
Tip: use ← and → keys to move between chapters.