How to implement things like Upvotes, Downvotes, Total-views, Likes without crashing the server

I don't even know how to google or describe such, Is there a word for this? How do Youtube view counts, Facebook Likes, Reddit Upvotes and Downvotes work?

There is no way these big guys send a POST or UPDATE request to the server every single time someone hits a like, upvote, or watches a youtube video, It would crash the server, So how do they do it? Since it's updated in real time I would suspect streaming protocols like UDP is used?

In my case I don't need to update it in real time, Every few minutes will do, What is the go to way for something like this? Where do you even collect the votes if it's not allowed to be send to the server every time someone votes

3 thoughts on “How to implement things like Upvotes, Downvotes, Total-views, Likes without crashing the server”

  1. If we think this way – everything can crush the server. But scalability is another thing to think about. Developers should focus on development.

    Open browser developer console, go to the network tab and choose “Fetch/Xhr”. Once you click the upvote button on this Reddit page, you’ll see a new \`POST\` request appears on the list.

    Reply
  2. There are a few techniques but you can get pretty far with caching and using background tasks, and some database replication/sharding.

    Steve Huffman, one of the co-founders of Reddit, created a course through Udacity many years ago and the later episodes talked about how they scaled Reddit.

    Check out this playlist and look at videos 399 onwards: [https://www.youtube.com/playlist?list=PLAwxTw4SYaPlLXUhUNt1wINWrrH9axjcI](https://www.youtube.com/playlist?list=PLAwxTw4SYaPlLXUhUNt1wINWrrH9axjcI)

    You might also be interested in how Instagram solved their Justin Bieber problem in their early days: [https://www.wired.com/2015/11/how-instagram-solved-its-justin-bieber-problem/](https://www.wired.com/2015/11/how-instagram-solved-its-justin-bieber-problem/)

    Reply
  3. > There is no way these big guys send a POST or UPDATE request to the server every single time someone hits a like, upvote, or watches a youtube video, It would crash the server, So how do they do it?

    There are many ways to do it. One of them is to have a microservice that takes care of upvoting and downvoting.

    Even if the service crashes, comments and any other related functionality will still work.

    Also if your services are containerized, you can easily limit how many resources they can use, so if a specific service is hit with tons of requests it won’t affect the server too much.

    Other than that, keep in mind most companies overestimate the resources they need. Unless you are a FAANG or a Fortune 500 company, chances are poor code and queries are to blame for your app’s bottlenecks, not the lack of bleeding edge architecture and technology.

    Reply

Leave a Comment