Lesson 7 of 15
37. Design a News Feed

37.6 Fan-out on write or on read?

3 min read+10 XP

Step 5: Deep dives (10 minutes)

Chapter 23 compared them; here are the numbers at full size:

On write (push)On read (pull)
Cost per postOne write per follower: 40 billion a dayOne write
Cost per feed loadOne cache read~200 lookups and a merge: 14 million a second at peak
FreshnessSeconds to minutes (async)Always fresh
Inactive usersWasted writes (skip them)No waste
Celebrities50 million writes per postFine

Our pick: hybrid. Push for normal accounts (the vast majority of posts), skip inactive followers (halving writes to about 20 billion a day), and pull for celebrities at read time.

Memory code: "Push for most, pull for the giants, skip the sleepers."