Question presented to candidate:
"Design the home timeline for Twitter, the list of recent tweets from everyone you follow. Reads vastly outnumber writes, some accounts have tens of millions of followers, and a tweet should show up for followers within a few seconds."
What a strong answer should cover:
The read/write asymmetry (Twitter reported roughly 300K timeline reads per second against about 6,000 tweet writes per second in 2012) and why that favours precomputing timelines
Fan-out on write (push tweet ids into every follower timeline) vs fan-out on read (merge followees at read time), with the cost of each counted, not just named
The celebrity problem and the hybrid: push for normal accounts, pull high-follower accounts at read time and merge, with a threshold chosen from numbers
Timeline storage: capped in-memory lists of tweet ids, hydration from the tweet store, rebuilding a timeline for an inactive user on demand
Edge cases: deletes, unfollows, protected accounts, timeline cap and scrolling past it; what breaks first at 10x
Clarifying questions expected:
Chronological only, or ranked? (This answer is chronological; ranking is the news feed question.)
How many users, follows per user, tweets and timeline reads per day? What is the largest follower count?
How quickly must a tweet appear for followers, and how far back can a user scroll?
Code / implementation expected: Optional โ counting writes and reads for push, pull and hybrid on a skewed follower graph, and showing all three produce the same timeline; the example does both.
twitter
timeline
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Engineers preparing for a system design round. You know what a cache and a database are; the timeline-specific ideas are defined as we go.
Difficulty: Hard
Verified with: Node 22.22 and Python 3.12 (both print identical output). Twitter figures are from published talks and write-ups cited inline, checked in October 2026.
How to read this doc: Plain language first, then ๐ Interview term: callouts with the precise vocabulary. The cost table is computed by the example program and quoted in full in the Verified section. This page is about the chronological home timeline and its fan-out; the ranked version (scoring, sessions, seen-state) is How would you design a news feed system?.
1. Why This Even Matters โ A Story First
A school has a noticeboard outside every classroom. When a tea
The solution is hidden so you can try first
14 min read ยท 16 sections
4
Read the code
Home timeline fan-out: push vs pull vs hybrid on a skewed follower graph, and the same timeline from all three via a k-way merge