Workflow

The general workflow will be:

For posting a comment:

  • Comment Posting process begins with the client submitting a comment, triggering an API request for posting. This request is initially directed to the load balancer, which efficiently routes it to the web services.
  • User Authentication takes place at this stage, ensuring that only logged-in users can proceed with posting comments. Once authenticated, the request is forwarded to the post services, which, in turn, push it to the Comment Queue.
  • Comment Upload Services then pulls the request and then stores the comment in the database and also initiates a request to increment the comment count. It also sends a notification to the user about the successful comment post by pushing the notification into the Notification Queue.
  • Comment Count Services, dedicated to managing comment counts, increment the count and persist it in the database on batch, which reduces the writes on the database hence reducing the database overload.

When Video is liked or disliked:

When a user likes or dislikes a video, several steps ensure everything works smoothly.

  • User’s Action starts with an API request sent to the load balancer, which directs it to the API services. These services make sure the request is genuine with the help of Authentication Services. Once confirmed, the request is passed to the Post Services and put into the Like Queue.
  • Like Finder pulls the request from the queue and checks if the user has liked or disliked the video before using Elasticsearch. If they have, the Finder updates the user’s choice and records the time it happened .
  • Like/Unlike Count Services come into play, managing how many likes and dislikes the video has. They update these counts in batches, which means they group changes together to make things more efficient.
  • Updated Counts are stored in the database and, if it’s there, in a cache for quicker access. To keep the user informed, a notification is sent.
  • Like/Unlike Count Services send a notification to the user through the Notification Queue. This whole process keeps data accurate and the system running smoothly, so users get a great experience.

For Pulling the read count

When a user clicks on a video to play it, a chain of actions is set in motion. An API request is triggered to gather metadata about the video. This request travels through the load balancer, which then directs it to the API Services. The API Services further guide the request to the Read Services, where ElasticSearch is utilized to search for the requested data within the cache.

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:...