Pattern
Fan-out
Problem
One event or write must be distributed to many consumers or write destinations.
Context
A new post → notify N followers; a config change → push to N services; a user action → update N cached views.
Solution
Publish the event once to a broker (pub/sub, event bus). The broker delivers to each subscriber. For 'push-based' fan-out (write to N destinations synchronously), use a fan-out worker with parallel writes and per-target retries.
Trade-offs
- Fan-out amplification: 1 event × 1M consumers = 1M messages
- Slow consumers can cause backup (with per-consumer queues, this is contained)
- Ordering across consumers is usually not guaranteed
Failure modes
- One target is slow and slows the whole fan-out (mitigate with async + timeouts)
- Fan-out storm on a viral post overwhelms the broker
- Duplicate deliveries because the broker retries on ACK loss
When to use
- Notification systems (post to 1M followers)
- Cache invalidation across regions
- Multi-consumer analytics pipelines
When NOT to use
- Single-consumer pipelines
- Ultra-low-latency real-time paths where fanning out adds too many hops