What happens when the user clicks the like/dislike button again?

We don’t want our users to like and dislike an already liked/disliked video. But, what should happen if a user likes or dislikes a video again:

  • If a user likes an already liked video, then we have to undo the like and decrement the like count.
  • If a user dislikes an already disliked video, then we have to undo the dislike and decrement the dislike count.
  • If a user has disliked the video and then clicks on the like button, then we have to undo the dislike and decrement the dislike count and then increment the like count and like the video.
  • If a user has liked the video and then clicks on the dislike button, then we have to undo the like and decrement the like count and then increment the dislike count and dislike the video.

We have to create a metadata which stores information about if a user has already like or disliked the video.

Design a system to count likes, dislikes and comments on YouTube videos

YouTube is the world’s largest video-sharing platform, with billions of users uploading and consuming content daily. The success of a YouTube video can be measured in various ways, including the number of likes, dislikes, and comments it receives. Tracking these engagement metrics is essential for content creators and the platform itself.

Important Topics for Designing System that Counts Likes, Dislikes and Comments on Youtube Videos

  • Requirements
  • Capacity Assumptions
  • High-Level Design
  • What happens when the user clicks the like/dislike button again?
  • Database Design
  • Communicating with the servers:
  • Microservices Used
  • Workflow
  • Scalability Considerations
  • Conclusion

Similar Reads

Requirements

Functional Requirements...

Capacity Assumptions

To estimate the scale of the system and to get the idea about the storage requirements, we have to make some assumptions about the data queries and the average size of videos uploaded....

High-Level Design

The design is read intensive as more users will fetch the comments and likes/dislikes than the users who will actually comment and like the videos. At a high level, our system will need to handle two core flows:...

What happens when the user clicks the like/dislike button again?

We don’t want our users to like and dislike an already liked/disliked video. But, what should happen if a user likes or dislikes a video again:...

Database Design

VideoStats...

Communicating with the servers:

We will use the rest API to request and post all data through the API Servers....

Microservices Used

Let’s drill deeper into each microservices:...

Workflow

The general workflow will be:...

Scalability Considerations

Our setup is highly scalable:...

Conclusion

In this article, we have explored a scalable architecture to track YouTube-scale video statistics:...