Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 33

Design like counts for very popular posts

Intermediate · 35 min · Storage & data modeling

Every post shows a like count and a heart that is filled in if you liked it. Most posts collect a handful of likes, but when a very popular account posts, hundreds of thousands of people tap like within a minute, and every one of the millions of people viewing the post sees the count.

Requirements

  • Like and unlike a post; a user can like a given post at most once.
  • Show the like count on every post view, and whether the viewer has liked it.
  • The viewer's own like or unlike is reflected immediately on their screen.
  • The displayed count must converge to the true number of current likers.

Constraints and assumptions

  • 2 billion like or unlike actions a day: about 23,000 per second on average and 100,000 at peak.
  • A single post can receive 50,000 likes per second for several minutes.
  • Count reads run about 50 times higher than likes: up to 1 million per second at peak, with p99 under 20 ms.
  • A count may lag by a few seconds. Above 10,000 it is displayed rounded (12.4K), so small drift is invisible; below that it should be exact once settled.

Out of scope for the first sketch

Pushing count changes live to open screens · The full list of who liked a post · Reactions other than like

Draw your design

Rough math and notes

Done on paper? Compare with the worked approaches