Design Case StudiesAdvanced18 min read2 questions

Design a News Feed (Twitter / Facebook Timeline)

The canonical fan-out problem. Why neither pure push nor pure pull works at scale, and how the hybrid model that every major platform actually uses is derived.

Covers: Fan-out on write vs read, the celebrity problem, hybrid fan-out, feed ranking, pagination, storage sizing

The news feed is the most instructive case study in the catalogue because the naive designs fail in opposite directions, and the correct answer is a hybrid you can derive from first principles rather than memorise.

Requirements and numbers

  • Functional: post; follow; view a ranked feed of posts from people you follow; infinite scroll.
  • Scale: 300 M DAU, average 200 follows, 2 posts/user/day, 20 feed loads/user/day.
  • Writes: 600 M posts/day ≈ 7,000/s. Reads: 6 B feed loads/day ≈ 70,000/s, ~200,000/s peak.
  • Latency: feed loads in under 200 ms p99. New posts appear within seconds, not necessarily instantly.
  • Skew: the most-followed accounts have 100 M+ followers. This single fact breaks the obvious design.
Filter
0/2 mastered
AdvancedfanoutfeedscalingAsked at Meta, Twitter

30-second answer

Fan-out on write pushes each new post into every follower's precomputed feed, so reads are a single fast lookup - but a celebrity with 100 million followers generates 100 million writes for one post, which is unacceptable. Fan-out on read builds the feed at query time by fetching recent posts from everyone you follow, so writes are cheap but a read touches hundreds of timelines and cannot meet a 200 ms budget. The answer is hybrid: fan-out on write for ordinary users, and fan-out on read for the small number of accounts above a follower threshold, merging both at read time.

AdvancedrankingpaginationfeedAsked at Meta, Twitter

30-second answer

Rank in two stages: cheap candidate generation to get a few hundred posts, then a scoring pass combining recency, affinity with the author, engagement signals and content type. Serve with cursor pagination, never offset - with a constantly changing feed, offset causes users to see duplicates and miss posts, because rows shift between requests. The cursor should encode the ranking position and a snapshot identifier so a scrolling session stays stable even as new posts arrive.

Showing 2 of 2 questions for design-a-news-feed-system.

Check your understanding

4 questions · no sign-up, nothing stored

0/4 answered
Question 1

1.Why is pure fan-out on write unworkable for a celebrity account?

Question 2

2.Why store post IDs rather than post content in each follower's feed list?

Question 3

3.A user scrolls while 12 new posts arrive. What does offset pagination cause?

Question 4

4.Which optimisation typically reduces fan-out work the most?

Hands-on challenge

Build it - this is what you talk about in a deep-dive round.

Design and size a news feed for 300M users

Produce the full design with numbers. The deliverable is a document a staff engineer would accept.

Requirements

  • Derive the celebrity threshold from measured cost rather than asserting a number.
  • Specify the write path for both strategies and the read-time merge.
  • Handle the two boundary cases: a user crossing the threshold, and newly followed celebrities.
  • Design cursor pagination with a pinned candidate set, including cursor contents and TTL.
  • Size Redis, post storage and the social graph, showing the arithmetic.

Stretch goals

  • Design post deletion propagation across 5 million precomputed feeds.
  • Add a ranking A/B framework with a safe fallback when the model service fails.