Fan-Out on Write vs Fan-Out on Read: Which Should You Use?
Compare push vs pull feed models, the celebrity problem, and why large platforms use a hybrid fan-out strategy for timelines.
Expected Interview Answer
Fan-out on write pre-computes each follower’s feed the instant content is created, pushing a copy into every follower’s inbox so reads are cheap and instant, while fan-out on read computes a user’s feed on demand by pulling and merging content from everyone they follow at request time, keeping writes cheap but making reads more expensive — the classic choice hinges on whether the workload is read-heavy with a normal follower distribution (favor write) or has celebrity accounts with millions of followers (favor read, or a hybrid).
Fan-out on write (push model) does the expensive work upfront: when a user posts, the system writes that post’s ID into the timeline/inbox of every one of their followers, so any follower’s feed read is just a fast lookup of their own precomputed inbox. This is ideal for typical social graphs where most accounts have a modest follower count and reads vastly outnumber writes, but it breaks down for celebrity accounts with millions of followers, since one post would trigger millions of writes (the “celebrity problem”), overwhelming the write path and wasting storage on inboxes that may never be read. Fan-out on read (pull model) flips this: nothing is precomputed at post time, and instead, when a user opens their feed, the system fetches recent posts from everyone they follow and merges them on the fly, which keeps writes cheap regardless of follower count but makes every feed read expensive, especially for users following many accounts. In practice, large systems like Twitter use a hybrid: fan-out on write for normal accounts, and fan-out on read (merged in at request time) for celebrity accounts, getting the best of both.
- Fan-out on write makes feed reads extremely fast — ideal for read-heavy, normal-follower-count workloads
- Fan-out on read keeps the write path cheap and avoids wasted storage for rarely viewed inboxes
- A hybrid model solves the celebrity problem without sacrificing read latency for most users
- Choosing correctly avoids either a write-amplification meltdown or a read-latency meltdown at scale
AI Mentor Explanation
Fan-out on write is like a scoreboard operator immediately updating every single spectator’s handheld score tracker the instant a run is scored, so every fan glances down and sees the score instantly with zero delay. Fan-out on read is like spectators only checking the big stadium screen when they personally choose to look up, meaning the system does no work until someone actually looks. Pushing updates to every handheld device works great for a small local match but becomes overwhelming when the “batter” is a global superstar being watched by millions simultaneously — that is the celebrity problem, solved by falling back to the shared big screen for superstar matches instead of pushing to every individual device.
Step-by-Step Explanation
Step 1
Characterize the follower distribution
Check whether the social graph is roughly uniform (most accounts have similar follower counts) or has “celebrity” accounts with orders-of-magnitude more followers.
Step 2
Estimate the read/write ratio
A read-heavy workload (feeds checked far more often than posts are made) favors precomputing on write; a write-heavy or bursty workload favors computing on read.
Step 3
Pick a base strategy
Default to fan-out on write for normal accounts to keep reads fast; default to fan-out on read for accounts whose write fan-out would be enormous.
Step 4
Blend for celebrities (hybrid)
At request time, merge the precomputed feed (fan-out on write) with on-the-fly fetched posts from followed celebrity accounts (fan-out on read) into one combined timeline.
What Interviewer Expects
- Correctly defines both push (write) and pull (read) fan-out models
- Explains the celebrity problem and why pure fan-out on write breaks for high-follower accounts
- Proposes a hybrid model as the real-world solution (e.g., Twitter’s approach)
- Reasons about the trade-off in terms of read/write ratio and follower distribution, not just memorized rules
Common Mistakes
- Picking one model unconditionally without discussing the celebrity/hot-account problem
- Not mentioning storage cost of precomputed inboxes for fan-out on write
- Ignoring that fan-out on read has high read latency for users following many accounts
- Failing to propose a hybrid approach when asked how a real system like Twitter/Instagram handles it
Best Answer (HR Friendly)
“Fan-out on write means when someone posts, we immediately deliver a copy of that post into every follower’s feed, so viewing your feed later is instant. Fan-out on read means we wait until someone actually opens their feed, and only then go fetch the latest posts from everyone they follow. The tricky part is celebrity accounts with millions of followers — pushing to everyone at post time would be far too expensive, so most large platforms use a mix of both approaches.”
Code Example
CELEBRITY_FOLLOWER_THRESHOLD = 1_000_000
def on_new_post(author_id, post_id):
if get_follower_count(author_id) < CELEBRITY_FOLLOWER_THRESHOLD:
# Fan-out on write: push into every follower's precomputed inbox
for follower_id in get_followers(author_id):
timeline_store.push(follower_id, post_id)
else:
# Celebrity: skip fan-out entirely, post is only stored once
celebrity_posts_store.save(author_id, post_id)
def get_feed(user_id):
# Precomputed feed from normal accounts (fan-out on write)
feed = timeline_store.get(user_id)
# Merge in celebrity posts on demand (fan-out on read)
for celeb_id in get_followed_celebrities(user_id):
feed.extend(celebrity_posts_store.recent(celeb_id))
return sorted(feed, key=lambda p: p.created_at, reverse=True)Follow-up Questions
- How would you decide the follower-count threshold for switching from push to pull?
- What storage cost does fan-out on write incur, and how would you bound it (e.g., only keep the last N post IDs per inbox)?
- How does a hybrid model merge and re-rank posts from both the push and pull paths at read time?
- How would caching change the calculus for fan-out on read?
MCQ Practice
1. What is the main advantage of fan-out on write (push model)?
Fan-out on write does the expensive work at post time, so reading a feed later is just a fast lookup of the precomputed inbox.
2. What is the “celebrity problem” in feed architecture?
Pure fan-out on write breaks down for accounts with millions of followers because one post would require millions of individual inbox writes.
3. How do large-scale social platforms typically solve the celebrity problem?
A hybrid approach avoids the write storm from celebrity posts while keeping feed reads fast for the vast majority of normal accounts.
Flash Cards
Fan-out on write? — Push model: a new post is immediately written into every follower’s precomputed feed/inbox.
Fan-out on read? — Pull model: a feed is computed on demand by fetching and merging posts from followed accounts at request time.
Celebrity problem? — A high-follower account’s post triggers an overwhelming number of fan-out-on-write inbox updates.
Common real-world solution? — A hybrid: fan-out on write for normal accounts, fan-out on read for celebrity accounts, merged at read time.