DBRaven
Pattern · read scaling

Fan-Out on Read

established

Summary

Compute a user's feed or aggregated view at read time by fetching and merging the most recent content from all followed accounts, rather than pre-computing and materializing the feed at write time: trading higher read latency for dramatically lower write amplification, especially for accounts with millions of followers.

Problem

Fan-out on write creates unbounded write amplification proportional to follower count. Celebrity accounts with millions of followers make fan-out on write prohibitively expensive. Fan-out on read eliminates write amplification at the cost of higher read-time computation for feed assembly.

Description

In social feed systems, two strategies exist for assembling a user's feed:

Fan-out on write (push model): when account A posts, immediately write a copy of the post reference to every follower's feed. A follow-graph with 1 million followers produces 1 million writes per post. The feed is pre-materialized and fast to read (a single range scan over the user's pre-built feed list).

Fan-out on read (pull model): store posts only once. When user B requests their feed, fetch the most recent posts from all accounts B follows, merge, rank, and return. For a user following 500 accounts, reading the feed requires 500 lookups plus a merge. No write amplification on post creation.

Fan-out on read is the correct model for high-follower accounts: a post from a celebrity with 50 million followers would require 50 million writes under fan-out on write: saturating the write path for minutes. Under fan-out on read, the post is written once and fetched on demand by each viewer.

In practice, large social platforms use a hybrid: fan-out on write for normal accounts (low follower count, frequent reads), fan-out on read for high-follower accounts (would cause prohibitive write amplification). The threshold is typically 10,000-100,000 followers. Twitter, Instagram, and Facebook all documented variants of this hybrid approach.

The hybrid implementation has two moving parts. At post creation, a poster under the threshold gets fan-out on write (the post reference is written to each follower's pre-built feed); a poster over the threshold gets a single write to their own post store, deferring assembly to read time. At feed read time, the user's pre-built feed (from fan-out-on-write contributors) is read first, then recent posts from high-follower accounts the user follows are fetched separately, merged with the pre-built feed, ranked, and truncated to the top K results.

Threshold selection is a direct write-amplification calculation: at a 10,000-follower threshold and 100 posts/day from a high-follower account, the system would fan out 1 million writes/day per account if that account were still below threshold, which is exactly the amplification the threshold exists to avoid.

Tradeoffs

Write amplification
+0.8

Eliminates write amplification on post creation; a post is written once regardless of follower count

Follow-graph consistency
+0.5

Naturally handles account follow/unfollow without feed repair, since the read-time merge reflects the current follow graph

Storage efficiency
+0.5

One copy of each post regardless of follower count

Read latency
-0.5

Read latency is proportional to the number of followed accounts, fetching and merging N accounts' recent posts

Caching complexity
-0.3

Cache strategy is more complex, since a pre-built feed list per user cannot simply be cached

Ranking cost
-0.3

Feed ranking (machine learning models) applied at read time adds computational cost per feed request

Hybrid classification overhead
-0.2

In the hybrid model, accounts must be classified as high/low follower and routed accordingly, and that classification must be kept up to date

When to use

The system includes accounts with very high follower counts (>100,000)

Write amplification at high follower counts makes fan-out on write operationally infeasible

Post creation frequency is high and follower fan-out is the write bottleneck

If write amplification is not the bottleneck, fan-out on read adds read latency for no benefit

Followers are willing to accept slightly higher feed latency for high-follower accounts

Fan-out on read reads are N × single-account lookup latency; pre-materialized feeds are faster

Used in a hybrid model: fan-out on write for normal accounts, fan-out on read for high-follower

Pure fan-out on read is slower for all users; the hybrid targets the specific amplification problem

When not to use

All accounts have bounded follower counts (e.g., enterprise B2B product where max followers is tens)

Fan-out on write works fine at low follower counts and provides faster reads

Feed requires real-time consistency: the latest post must appear for all followers immediately

Fan-out on read fetches from the followed account's store, which may have propagation delay

Operational Requirements

mandatory

Maintain a continuously updated set of high-follower accounts for routing

A following relationship update may cross the threshold and change which path a post takes.

mandatory

Cache high-follower account post lists aggressively

These are read by every follower on feed request, so they are the hottest read path.

recommended

Monitor fan-out-on-read latency separately from fan-out-on-write latency

The two paths have different P99 profiles and should not be conflated in one latency metric.

Characteristics

Scales on
Implementation complexitymedium
Operational complexitymedium

Relationships

Complements

fan out on writematerialized viewcqrscache aside

Basis

Fan-out on read and the hybrid model are documented in Twitter Engineering blog posts (Project Manhattan), Instagram engineering content, and distributed systems literature on social feed architecture

Related Architecture Knowledge

Outbound: this entity affects

ComplementsPattern
fan out on write
Grounded

Fan-out on read and fan-out on write are used together in a hybrid social feed model: normal accounts use fan-out on write for fast reads; high-follower accounts use fan-out on read to avoid write amplification.

Full relationship →
ComplementsPattern
materialized view
Grounded

Fan-out on read for high-follower accounts can be accelerated by maintaining a materialized view of each account's recent posts, reducing the per-follower fetch to a single indexed lookup per followed account.

Full relationship →

Used In Architecture Scenarios