Try
↑ ↓ move↵ openesc close
In this lesson · topic 5 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 5

The hybrid and its threshold

6 min read

Split by follower count

A hybrid feed treats accounts differently. An account below a follower threshold is pushed to its followers’ inboxes. An account at or above it is not. Its posts stay in its own timeline.

When a reader opens a feed, the service reads the reader’s inbox and then pulls the latest posts of any celebrity the reader follows. It merges the two lists by time. Most readers follow only a few celebrities, so the extra work is small.

The lab has 13 accountsmeasured at or above 200 followers. With those pulled, the largest single push was 196 insertsmeasured, down from 972 insertsmeasured. At a skew of 1.5 the 99th percentile write lag was 0.7 ticksmeasured in hybrid mode against 6.2 ticksmeasured in push mode.

What it costs

Pull mode made 1 insertmeasured per post and reads averaged 35.5 msmeasured. The hybrid sat between the two. It made 14.1 insertsmeasured a post, and reads averaged 14.5 msmeasured with a 99th percentile of 20.5 msmeasured.

Pulled timelines also become hot. In the lab the busiest author’s timeline took 97 reads a tickmeasured in hybrid mode. A celebrity timeline is a small, hot, read-mostly object, which is what a cache is for. See caching. Cache it, and keep a copy on each feed server.

Choosing the threshold

The threshold slides you along the trade-off. Lower it to 50 followers and more accounts are pulled. Writes get cheaper, with 9.0 insertsmeasured a post, and reads get slower, at 22.1 msmeasured on average.

Pick it from two numbers: how much write capacity you have for one post, and how many pulled fetches a read can afford. Some designs also look at activity. A quiet account with many followers can be pushed, and a very active one with fewer can be pulled.

An account that crosses the threshold must change mode. Decide what happens to its old posts. A simple rule is to pull from then on and leave earlier copies where they are.

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