Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 50

Design live like count updates

Intermediate · 35 min · Real-time delivery

When you look at a post, its like count ticks up while you watch, without refreshing. As you scroll, different posts come into view and should start updating, and posts you scrolled past should stop. The like counts themselves already exist in a separate counting service.

Requirements

  • While a post is on screen, its displayed like count updates live.
  • Updates start when a post scrolls into view and stop when it leaves view or the app goes to the background.
  • A viewer's own like shows instantly and is never undone by a slightly stale update.
  • The count on screen never jumps backwards because updates arrived out of order.

Constraints and assumptions

  • 50 million clients connected at peak, each with about 5 posts on screen; scrolling changes about one subscription per client every 5 seconds.
  • The counting service emits about 100,000 count changes per second in total; one viral post can change 50,000 times per second.
  • A change should be visible on watching screens within 2 seconds.
  • Clients have limited battery and bandwidth: no more than one update per post per second is useful.

Out of scope for the first sketch

How likes are recorded and counted durably · Comments and other live features · Notifications to the post author

Draw your design

Rough math and notes

Done on paper? Compare with the worked approaches