Who Liked This
Design the like and reaction system behind every post in a large social feed.
Requirements
Functional: a user can like, unlike, or switch reaction on a post; every rendered post shows a total count and whether the viewing user liked it; a post detail page can page through the list of likers, newest first.
Non-functional: the write must ack fast and never block on aggregation; the viewer's own like state must be correct immediately after their own action; the total count may lag but must converge; a single viral post must not become a write bottleneck.
Scale
300M DAU, about 20 like actions per user per day, so roughly 6B writes/day (70k writes/s average, 200k at peak). Feed rendering asks for count plus viewer state on about 144B posts/day (1.7M/s average, 3M/s peak), batched 40 posts per request. A like row is about 48 bytes on disk, so raw growth is near 290 GB/day before replication. A viral post can take 500k likes in five minutes, which is 1.7k writes/s aimed at one post id. Target p99 of 150 ms for the write ack and 30 ms for a batched read served from cache. Counts may be up to 2 seconds stale.
Out of scope
Notification fanout to the post author, feed ranking, bot and spam detection models, media storage, and the comment system.
Sign in to answer questions and track your progress
Sign In