Skip to main content
Common Designschapter 3 of 8 · 4 lessons

News Feed / Timeline

Aggregate, rank, and serve personalized posts from accounts you follow.

Someone with 200 followers posts a photo. Someone with 50 million followers posts a photo. Both should appear in their followers' feeds within seconds.

Do the work when they post, and the first case is 200 quick writes and the second is 50 million, which will still be running an hour later while the queue behind it backs up.

Do the work when somebody opens the app instead, and posting is instant, and every feed open now has to gather and merge posts from the 400 accounts that person follows, at 20,000 feed opens a second.

Neither answer survives on its own, and the reason is that your follower counts are not evenly spread. That single fact shapes every feed system in production.

Lessons

4 in this chapter
  1. Requirements and EstimationFeeds are read 100 times more than they are written, but fan-out multiplies every write.2 min
  2. Fan-out on Write vs Fan-out on ReadPush for the many small accounts, pull for the few giant ones, merge at read time.3 min
  3. The Serving ArchitectureStore IDs in the feed cache, hydrate the content at read time, and rebuild lazily for the inactive.3 min
  4. Ranking and PaginationCursors keep infinite scroll stable; ranking is a candidate-scoring layer on top of the same plumbing.3 min