Skip to main content

Fanout Patterns

Difficulty: Medium | Topic #22

What to Learn

Fan-out-on-write (push model — pre-populate each follower's feed) vs fan-out-on-read (pull model — compute feed at read time); hybrid approach for celebrities, tradeoffs in storage vs latency.

Resources

Covered by Problems

ProblemDifficultyLink
Social News Feed (FB News Feed)Medium
Photo Sharing (Instagram)Medium
News AggregatorMedium

Key Concepts to Master

  • Fan-out-on-write: low read latency but huge write amplification for celebrities
  • Fan-out-on-read: avoids write amplification but high read latency for active users
  • Hybrid approach: fan-out-on-write for normal users, pull for celebrities (Twitter/X strategy)
  • Inbox vs outbox model for activity feeds
  • Ranked feed vs chronological feed storage implications