Try
↑ ↓ move↵ openesc close

Curriculum · Module 10, Design Walkthroughs

Lesson 2 · 7 topics · 34 min · Intermediate · 0/7 done

Design a news feed

Build a timeline for each reader. Push on write makes reads cheap and breaks on celebrities, pull on read does the reverse, and a hybrid splits accounts by follower count.

What each topic covers

  • A feed shows each reader the recent posts of the accounts they follow. The work can be done when a post is made or when a feed is read, and both can hurt.
  • Size a feed service, then define the calls and the three tables behind them.
  • Build feeds for 1,000 users in each mode and raise the follower skew to see write backlog and read time move.
  • Push cost follows the author's follower count, so a few huge accounts flood the writers and delay posts for everyone.
  • Push for ordinary accounts, pull for the few big ones, and merge the two when a feed is read.
  • Keep ids in a capped list per reader, and page with a cursor so new posts do not shift the pages.
  • Three quick checks on push cost, the hybrid and paging, with the sources behind the lesson.

Topics

  1. 1One post, a million timelines4 min
  2. 2Requirements, numbers, API and data model4 min
  3. 3Push, pull and hybrid in the lab8 min
  4. 4The celebrity problem4 min
  5. 5The hybrid and its threshold6 min
  6. 6Feed storage and pagination5 min
  7. 7The news feed in review3 min

Practise this lesson

8 interview questions on news feed, with worked answers and sources.

Practise these

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