#📝 Note: Fan-Out Pattern

#Overview

Fan-out is the strategy of copying or delivering a message/event from one source to many destinations. The central trade-off is write amplification vs read latency: fan-out-on-write is fast to read but expensive to write; fan-out-on-read is cheap to write but slow to read.

#Core Idea

#Fan-Out-on-Write (Push Model)

When a user posts/acts, immediately propagate the result to all followers' inboxes.

#Fan-Out-on-Read (Pull Model)

When a user opens the feed, fetch content from all followed accounts in real-time.

#Comparison Table

Aspect Fan-Out-on-Write Fan-Out-on-Read Hybrid
Read latency O(1) fast O(N) slow O(1) for most
Write cost O(N) expensive O(1) cheap Mixed
Storage High (duplicated) Low Moderate
Celebrity problem Write storms Read storms Solves both
Stale data risk Low None Low

#When to Use

#When NOT to Use

#Trade-offs

#Used In This Repo