SDE Path

News feed fan-out

Design Twitter (News Feed)

Hard

Turn one tweet into millions of home timelines — without melting on the celebrity who has 100M followers.

Twitter's core is the home timeline: the reverse-chronological (or ranked) feed of tweets from everyone you follow. Posting a tweet is a tiny write; reading timelines is a firehose — reads outnumber writes by more than an order of magnitude, so the whole design is about precomputing each user's feed instead of recomputing it on every open.

The defining crux is fan-out: when you tweet, how does that tweet reach the home timelines of all your followers? Push it eagerly at write time, pull it lazily at read time, or both? And what happens when the author is a celebrity with ~100M followers — one tweet becoming a hundred million timeline writes? That hot-user problem is what separates a toy answer from a real one, and it forces a hybrid fan-out strategy.

Scope it fast. The interviewer wants you to name home-timeline generation as the crux and to separate the home timeline (a fan-in of tweets from many people you follow) from the user timeline (one author's own tweets). The heavy read:write asymmetry — reads dominate writes ~20:1 — is the fact that drives every later decision toward precomputing feeds.

Functional

  • Post a tweet (text + optional media) that lands in followers' home timelines.
  • Follow / unfollow users — the social graph that defines whose tweets you see.
  • View the home timeline — recent tweets from everyone you follow, cursor-paginated.Reverse-chronological to start; ranking is a later layer over the same candidate set.
  • View a user/profile timeline — a single author's own tweets.

Non-functional

  • Read-heavy — home-timeline reads outnumber tweet writes ~20:1 on average and far more at peak; the read path must be cheap.
  • Low read latency — home timeline < 200 ms p99, served from precomputed cache.
  • High availability — feed reads target 99.99%; a stale-by-seconds feed is fine, an unavailable one is not.
  • Eventual consistency of feeds — a new tweet may appear in followers' timelines after a few seconds of fan-out lag.
  • Scale — ~200M DAU, ~5,000 tweets/s average, ~1M fan-out timeline writes/s.

Out of scope

  • Search / trending topics
  • Direct messages
  • Ads & monetization
  • Spam / abuse ML detection

Check yourself· 3 questions

Question 1

Which single problem is the hardest part of this system and shapes the whole design?

Question 2

Why is a home timeline harder to build than a user (profile) timeline?

Question 3

Which non-functional requirement most directly justifies precomputing (materializing) timelines?