SD-33 · LIKE COUNTS AT SCALE · INTERACTIVEBreak it.
Break it.
Then fix it.
A famous person just posted. Turn up the likes, watch which single number melts first, and add the parts a real like service needs. Every switch is a decision you would defend in an interview.
CHALLENGETake 100K likes/s, 20% of them on one post, with count reads under 20 ms p99, likes under 100 ms p99 and no double counts.
StatusDOWNAt 50K likes per second
Count read p99184 msTarget under 20 ms
Like p99500+ msTarget under 100 ms
Errors90%Requests being dropped
Monthly cost$5,220One like database
UsersLIVE
50K likes/s · 500K count reads/straffic source
API gatewayOK
Auth, limits, autoscalespreading 550K/s
Like API × 16OK
Stateless550K / 800K ops/s
Counter storeDOWN
Hottest row: 10K updates/s500K reads · 50K writes/s
Like rowsDOWN
One database50K / 5.0K inserts/s
One database can't take the inserts. 50K like rows a second against a limit of 5,000. Shard by user_id, not post_id, so a famous post's likers spread over all 64 shards.
20%Likes on one postAt a peak moment one famous post can take a fifth of every like.
1/sHottest counter writesThe aggregator sums each post for 1 second, so 20,000 likes become one write.
64Shards by userSharding by who liked spreads a famous post's likes over every shard.
≈ 2 sCount lagOthers see a like within seconds; the liker sees it at once.
Want the reasoning behind every switch?Visual walkthroughFull write-up
Was this lab useful?Your vote tells us what to improve next.