Case study demo

News feed

Compare fan-out on write (push) and fan-out on read (pull) for building timelines.

An interactive demo of how this system behaves. It runs in your browser.

Case study · Live model

How a news feed is built

1,000 users each follow 20 others, and most follow 2 celebrities. Build feeds by push, pull or a mix, then let a celebrity post, and compare reads, copies and delays.

Try it

Lab time 3.0 s
workers copyreadsPosting users, 4 posts/sPosting users4 posts/s14 postsPost store, all postsPost storeall posts14 storedFan-out queue, 300 copies/sFan-out queue300 copies/s0 copies waitingFeed store, a feed per userFeed storea feed per user271 copies writtenFeed service, PushFeed servicePush1.0 reads per loadReading users, 20 loads/sReading users20 loads/s30% of users active
  • Posting users — 4 posts/s — healthy — 14 posts
  • Post store — all posts — healthy — 14 stored
  • Fan-out queue — 300 copies/s — healthy — 0 copies waiting
  • Feed store — a feed per user — healthy — 271 copies written
  • Feed service — Push — healthy — 1.0 reads per load
  • Reading users — 20 loads/s — healthy — 30% of users active
  • New post
  • Copies queued
  • Copies written
  • Feed opened
  • Database read
  • Feed shown
Reads per feed load
1.0
Feed load time
13 ms
illustrative: 10 ms + 3 ms a read
Copies written
94/s
Fan-out backlog
0
copies waiting; 0 posts not yet everywhere
Slowest post delivery
0.14 s
normal posts finished in the last 5 s
Copies for users who never read
70%
Watch: last 5 s

Numbers add up:271 copies queued = 271 written + 0 waiting; every stored feed holds only posts by accounts its user followsThe lab checks this sum as it runs, so a counting mistake would show here.

Controls

How feeds are built
Strategy

Fan-out on write: each new post is copied into every follower's stored feed.

300 copies a second

How fast the fan-out workers write copies into stored feeds.

Users
4 a second
20 a second
30%

Only active users ever open their feed.

Fan-out backlog (copies waiting)
012.52537.5501s2s3s
Show data table
TimeBacklog
1s30
1s0
2s0
2s0
3s0
3s7
Copies written per second
0501001502001s2s3s
Show data table
TimeCopies/s
1s35
1s121
2s142
2s56
3s15
3s87

What just happened

Nothing yet. Start traffic or run an experiment.

What this model simplifies
  • 1,000 users, each following 20 others at random. Real follow graphs are far more uneven, with many accounts in between normal users and celebrities.
  • Celebrities post only when you press the button. A pulled feed reads each followed account once; real systems cache those reads.
  • Feed load times are illustrative: 10 ms plus 3 ms per database read. Real pull reads run side by side, so the true cost is database load and slow outliers more than adding up.
  • Push copies a post to every follower. Real systems skip followers who have not logged in for a while, and keep only the newest few hundred posts in each feed.