Grokking the System Design Interview, Volume II
Vote

0% completed

YouTube Likes Counter: System Definition

Step 1: System Definition

Image

Step 1: System Definition

Problem statement. Design the backend that manages likes and dislikes for YouTube videos and comments. The system records each user reaction and updates the total counts. It also returns those counts with a short delay (low latency). It must serve millions of users at the same time and hold billions of past reactions.

Key entities. The system has four entities. The diagram shows them and how they connect.

Key entities and flow
Key entities and flow
  • User. A viewer with a unique userID, for example User A with id=123. Users create the reaction events.
  • Video. A content item with a unique videoID, for example Video V with id=XYZ1. The system tracks total likes and dislikes for every video.
  • Comment. A user's response to a video, with a unique commentID. Like videos, comments have total like counts.
  • Reaction (Like or Dislike). The link between one user and one specific video or comment. It records the type, Like or Dislike, and metadata like a timestamp. It is what lets the system answer "has this user already reacted to this item?" A user can toggle or remove a reaction at any time.

Real-world example. User Alice watches the video "Funny Cats" (videoID: abc123).

  1. Video interaction. Alice clicks the thumbs up button. The system records a Like linking Alice to the video. It then adds one to the video's like count.
  2. Comment interaction. Alice reads a comment (commentID: cmt99) and likes it. The system records that reaction and updates the comment's count.
  3. Two users at once. At the same time, user Bob clicks thumbs down on the same video. The system records a Dislike and adds one to the video's dislike count.

The system must accept these events and update the visible counts reliably. The counts must stay correct even when millions of users react to popular content at the same time.

Next: Step 2, where the requirements are defined.

On This Page

Step 1: System Definition