Follower timeline
Design the home timeline for a social product. People follow each other; when you open the app you see recent posts from everyone you follow, newest first. Some accounts have tens of millions of followers.
Where’s the slack?
Reads: ~200 ms. Post visibility: seconds. Counts: minutes.A reader cannot tell when a post was supposed to appear in their feed. So you have seconds of slack on delivery, and almost none on opening the app.
This is the key asymmetry. Opening the app has a hard budget: the timeline must render in a couple of hundred milliseconds or the product feels broken. But readers do not time when someone else's post shows up. If it appears two seconds after it was posted, or ten, the reader cannot tell, because they have no reference clock.
That slack is what makes fan-out on write possible. You can do a large amount of work asynchronously between "they posted" and "it appears in feeds", because readers are not watching that interval. The exception is the author, who knows when they posted and will often refresh at once. Their view of their own post has zero slack and needs a different path.
Counts (likes, replies, views) have minutes of slack. A reader cannot tell 4,102 from 4,118. That is what lets you batch and approximate them instead of writing to a contended row on every interaction.
So: Seconds of delivery slack means you can precompute timelines in the background rather than assembling them on read. Zero slack on the author's own view means you special-case it. Minutes of slack on counts means they never go near the hot path.
Work it through
Five stages, gated. You write your answer for each stage before its model answer unlocks. That is the core of the method.
Reference material for this problem. The diagrams below are here to check your own against once you have drawn it, not to read first.
The lifecycle
The numbers
So the hard part is fan-out amplification, and specifically its tail. The average says 300x; the worst case says 30 million, and the worst case is what takes the system down.
The architecture
The mechanism
The decision this turns on
- —Reads are one sequential lookup of a precomputed list. Fast and cheap.
- —Write cost is multiplied by the follower count.
- —A huge account turns one post into millions of writes and blocks the queue.
- —Storage grows with posts times followers, not with posts alone.
- —Writes are trivial: store the post once and stop.
- —Reads query every account you follow and merge, which is hundreds of lookups.
- —Perfect for huge accounts: their posts are read by millions, so cache hit rates are near 100%.
- —Hopeless at 20,000 timeline opens a second for ordinary users.
Follow-ups you should expect
Many interviews are decided in the follow-ups, not the first diagram.
Same shape, other products
One action by one person creates work for thousands of other people.
The question is always the same: do you do that work when they write, or when everyone else reads? And what do you do about the one user with 200 million followers?
Others with this shape: Twitter timeline · Chat delivery · Notification system · Activity feed
How it is really built
Write your own answer first. Then read how teams who run this at scale describe it. Their constraints were real, and the write-ups often say what their choices cost.
- Engineering at Meta ↗Fan-out and the celebrity problem, from the people who hit it first at this size.