Push vs Pull Fan-out
2 min read
For social fan-out, push-on-write is fast to read but expensive to write. Pull-on-read is the opposite. Real systems use both, chosen by follower count.
For social fan-out, push-on-write is fast to read but expensive to write. Pull-on-read is the opposite. Real systems use both, chosen by follower count.
How It Works
When one user's action generates updates visible to many others (tweets, feed posts, notifications), you have a fan-out problem with two strategies. Push-on-write: when the author posts, immediately write the post to each follower's precomputed feed. Reads are O(1) per follower, but writes are O(N followers) — catastrophic for celebrities with millions of followers. Pull-on-read: when a follower loads their feed, query across everyone they follow and merge. Writes are O(1) but reads are O(M × posts) — slow for active users. Real answer: hybrid — push for normal users (few followers), pull for celebrities (many followers), merge at read time. The threshold is engineering judgment, not a fixed rule.
Real-World Example
Twitter famously transitioned from pure pull-on-read (slow timelines for everyone) to pure push-on-write (fast timelines but celebrity fan-out killed the write path) to the hybrid: users with more than ~10,000 followers are pull-on-read; everyone else is push-on-write. Their transition was years-long and documented publicly. This is the canonical fan-out case study: the algorithmic complexity of fan-out forces a per-user routing decision, and the threshold choice is itself a tradeoff between write amplification and read latency.
Test Yourself
Scenario: You're designing a news feed. Follower counts range from 10 to 50M. Which fan-out strategy do you use, and where do you set the threshold?
Get notified when we launch
One email when the full practice product is live. No spam.