Fanout at Scale: Push vs. Pull Strategies in Distributed Systems
Source: Dev.to
Modern systems don’t fail because they can’t store data — they fail because they can’t deliver the right data to the right consumers at the right time.
The fanout problem is one of the most fundamental challenges in distributed systems, especially visible in social media feeds, notification systems, messaging platforms, and event‑driven architectures.
When a single event occurs, how do we efficiently deliver it to millions of consumers? The two dominant strategies are:
- Fanout‑on‑Write (Push)
- Fanout‑on‑Read (Pull)
Both are valid, widely used, and each comes with serious trade‑offs.
The Fanout Problem
- One write → many reads
- Goal: deliver low‑latency, personalized feeds to all followers, even when a user has millions of followers.
The naive solution—“just send the post to everyone”—collapses under:
- Write amplification
- Storage explosion
- Hot partitions
- Latency spikes
Fanout‑on‑Write (Push)
When a user creates content, the system immediately pushes the content to each follower’s precomputed feed.
How it works
User posts → System pushes post to N follower feeds
Advantages
- Ultra‑fast feed reads
- Predictable read latency
- Simple read queries (single lookup)
Costs / Trade‑offs
- Massive write amplification (e.g., a celebrity with 100 M followers generates 100 M feed writes for one post)
- Heavy storage usage
- Hot users can overload the system
Fanout‑on‑Read (Pull)
When a user opens their feed, the system pulls recent posts from the accounts they follow, merges, ranks, and filters them at read time.
How it works
User opens feed → System pulls content from many sources
Advantages
- Minimal write cost (no per‑follower writes)
- Scales well for users with extreme fanout (celebrities)
- Storage‑efficient
Costs / Trade‑offs
- More complex, expensive reads
- Higher read latency compared to push
- Harder to cache efficiently
Hybrid Fanout Strategies
Pure push or pure pull is rare at large scale; most platforms use a hybrid approach.
Selective Fanout
- Push for normal users (bounded fanout)
- Pull for celebrities or high‑fanout content
Why hybrid works
- Top ~0.01 % of users generate extreme fanout; pushing their posts would melt storage and queues.
- Precomputation, ranking models, and feed materialization are applied where they provide the most benefit.
Typical composition
- Precomputed feed entries (push)
- Dynamically fetched content (pull) – e.g., suggested posts, ads, reels
Domain‑specific hybrids
- Professional graphs (smaller, denser) → primarily push
- Interest‑based feeds (large, sparse) → primarily pull, using recommendation pools and ML‑ranked candidate sets
Fanout Beyond Social Feeds
| Strategy | Typical Use Cases | Key Characteristics |
|---|---|---|
| Push Fanout | Mobile push notifications, emergency alerts, trading alerts, cache invalidation, security patches | Uses message queues or topic‑based pub/sub, requires rate limiting, provides low‑latency delivery |
| Pull Fanout | Kafka consumers, Prometheus scraping, lazy fetching of rarely accessed assets | Consumers pull from partitions, enables backpressure, replayability, and fault isolation |
| Hybrid | Price ticks (push) + historical data (pull), kill‑switch updates (push) + periodic consistency checks (pull) | Balances bandwidth, latency, and storage constraints |
How to Choose the Right Fanout Strategy
Use Fanout‑on‑Write (Push) When:
- Read latency must be minimal
- Fanout size is bounded (e.g., most users)
- Storage is inexpensive and abundant
- Predictable performance is critical
Use Fanout‑on‑Read (Pull) When:
- Fanout size is unbounded (e.g., celebrities)
- Writes must remain cheap
- Consumer demand varies wildly
- Backpressure is required to protect downstream services
Hybrid Approach When:
- Both low‑latency reads for the majority of users and scalable handling of extreme fanout are needed
- You can precompute for a subset of content while pulling the rest dynamically
Think of fanout like logistics:
- Push = Home delivery – fast, predictable, but more expensive.
- Pull = Warehouse pickup – cheaper and flexible, but slower.
- Hybrid = Amazon Prime – combines fast delivery for high‑priority items with cost‑effective handling of the rest.