Design a like-count system for a large video platform with viral-video bursts
OracleSoftware Engineer · OnsiteLast updated
A system design question for the like feature of a large video platform. It probes one-like-per-user correctness, serving counts and viewer state at huge read volume, absorbing bursts of likes on viral videos, exact versus approximate counting trade-offs, counter reconciliation, and abuse protection.
Design the system behind the like button of a large video platform such as YouTube. Signed-in users can like a video and later remove their like; each video page shows the total like count and whether the viewer has liked it; users can open a list of the videos they have liked.
Interviewers in this loop cross-questioned design choices closely and also reserved about ten minutes of each round for behavioral questions, so cover the core write and read paths first and leave time to defend them.
Constraints and Clarifications
- Each user can like a given video at most once; repeated requests must not inflate the count.
- Scale is not given; state your own estimates, including how bursty a newly released popular video can be.
Clarifying Questions
- Are dislikes in scope, and if so, are their counts shown publicly?
- How fresh must the displayed count be, and may it be rounded?
- Are counts shown on thumbnails in lists and search results, or only on the video page?
- Must the user's own like appear instantly on all of their devices?
Hints
Hint 1
One click, how many writes?: Trace what a single like costs on a video receiving thousands of likes per second, and look for the write that turns into a hot spot.
Hint 2
Source of truth versus display: Ask which data must be exactly right for each user and which number can lag a little.
Follow-up questions
- A video receives 50,000 likes in its first minute. Walk through the load on each component.
- Counts for some videos have drifted from the true number. How do you detect and fix it?
- Likes from a bot network are discovered a week later. How do you remove their effect?
- How would you feed like events to a recommendation system without slowing the main path?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.