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