← Lessons

quiz vs the machine

Silver1110

System Design

Fan Out On Write

Precomputing follower feeds at post time so reads are cheap lookups.

4 min read · intro · beat Silver to climb

Push the work to write time

In fan out on write, also called push, the system does the heavy work the moment a post is created. It looks up every follower and inserts the post id into each follower feed, usually a per user list in a fast cache or store.

When a follower later opens the app, their feed is already assembled. The read is just a quick lookup of their precomputed list.

Why teams like it

  • Reads are extremely fast since the feed is already built.
  • The read path stays simple, just fetch a list by user id.
  • Load is spread out across the day as posts trickle in.

The cost

  • A post by an account with many followers triggers a huge write storm, one insert per follower.
  • Inactive followers still get writes they may never read, wasting work.
  • Feeds for users who follow thousands take a lot of storage.

Key idea

Fan out on write precomputes each follower feed when a post is made, making reads fast and simple at the cost of expensive writes for popular accounts.

Check yourself

Answer to earn rating on the learn ladder.

1. When does fan out on write do its main work?

2. What is the main drawback of fan out on write?

3. Why does fan out on write waste work?