Notesfoundations🌱 seedling
Fan-Out on Write
Also: Fanout on Write · Push Model · Write-Time Fan-Out · Precomputed Timeline
Fan-out on write does the work of assembling a feed when a post is written, copying it into every follower's precomputed timeline, so reads become a single lookup. It trades cheap reads for writes amplified by the follower count.
Why it exists
The naive fan-out on read stores each post once and joins across everyone you follow on every timeline view. When reads vastly outnumber writes (Twitter in 2012: ~300k timeline reads/s vs ~5k tweets/s), that puts the expensive join on the hottest path and repeats it for posts that haven't changed.
How it works
- On write: look up the author's followers, then insert a reference to the post into each follower's timeline (a cache or a partition per user). In effect each timeline is a Materialized View.
- Timelines are trimmed to a bounded length (Twitter: 800 entries in Redis, three replicas).
- Skip inactive users to save memory; rebuild their timeline on demand.
- Hybrid: accounts with huge followings are not fanned out. Their posts are stored once and merged into the reader's timeline at read time.
Trade-offs
| Gains | Costs |
|---|---|
| reads are one lookup, fast and predictable | write amplification proportional to follower count |
| expensive work moves off the read path | storage for every copy; wasted work for followers who never read |
| delivery delay for huge accounts (Twitter's p99 reached minutes) |
In practice
- Twitter (2012): tweets fanned out into Redis home timelines; it was working toward merging very large accounts in at read time.
- Bluesky (2025): fan-out into per-user timelines in ScyllaDB. Accounts following huge numbers of others made hot shards, so each write to their timeline is kept only with probability
min(limit / follows, 1)("lossy timelines"), cutting p99 fan-out time by over 96%.
Pitfalls
- Assuming one strategy fits every account: the follower distribution is heavily skewed, so most systems end up hybrid.
- Forgetting deletes and edits: they must fan out too.
Connections
- Part of
- Scalability
- Learn first
- Load Parameters
Recall
These cards are also in your review deck, scheduled with spaced repetition.