Try
↑ ↓ move↵ openesc close
In this lesson · topic 3 of 7
  1. 1. One post, a million timelines
  2. 2. Requirements, numbers, API and data model
  3. 3. Push, pull and hybrid in the lab
  4. 4. The celebrity problem
  5. 5. The hybrid and its threshold
  6. 6. Feed storage and pagination
  7. 7. The news feed in review

Topic 3

Push, pull and hybrid in the lab

8 min read

What the lab runs

Each tick, 20 posts are made by random authors and 100 readers open their feeds. Each user follows 20 accounts, picked by popularity with the skew you set.

In push mode a post is copied into every follower’s inbox. The writers can do 500 inserts a tick. Extra inserts wait in a backlog, and the lab reports how many ticks a post waited.

In pull mode a post is one write. A read fetches the latest posts of each followed account. In hybrid mode, accounts at or above a follower threshold are pulled and the rest are pushed.

Read time is modelled as 4 milliseconds plus 1.5 milliseconds for each fetch. The constants are invented to show shape. Real fetches overlap, so the real cost per fetch is lower.

Predict before you press play

You move from push to pull. Which numbers move?

tick 60 (1 tick = 1 second)push feedbiggest account 972 followers, 13 at or above 200

Writing posts

posts
1,200
inserts per post
21.4
largest single post
972 inserts
99th percentile lag
2.9 ticks

Each post is copied into follower inboxes when the mode pushes it. Writers can do 500 inserts a tick, so a very popular account makes a queue.

Reading feeds

mean read
5.5 ms
99th percentile read
5.5 ms
busiest timeline
0 reads a tick

A read fetches the reader's inbox, plus the latest posts of every account that is pulled. Each fetch adds time.

Write backlog after each tick, last 150 ticks
Write backlog after each tick, last 150 ticks. Text version available below the chart.050010001500200013160recent ticksinserts waiting

Full-page version with guided experiments: Feed fan-out lab.

Things to try

  1. Keep push mode and read the feed read time.
  2. In push mode, raise the follower skew to 15 tenths.
  3. Switch to pull mode.
  4. Choose hybrid at a skew of 15 tenths.
  5. Choose hybrid and lower the threshold to 50 followers.

The full-page lab has a guided experiment for each of these.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms