Scaling - System Design 01

Scaling - System Design 01

ยท

3 min read

Scaling is an important part of system design. Without scaling, no application can survive. In this blog, I will explain scaling with a real-world example, making it easy to understand, so everyone can learn the concept quickly.

Let's consider an example of an entrepreneur named Yash. He built a social media platform called "ConnectWithWorld."

His initial setup is as following:

  1. Technology: He is using MERN stack for the backend and frontend.

  2. Single Server: His application is hosted on single server.

  3. Traffic: Initially the traffic is not much. Its low to moderate most of the times. So single server is easily able to handle the load right now.

One day he shared his application on Linkedin and Twitter. His post went viral and lots of users started coming to his social media platform. They started using it daily and posting lots of videos, threads etc.

One day what happened is the platform started getting slow. Because it was not able to handle the amount of users who were using the platform and posting stuff, it went really slow. So Yash started researching about it and found out about Scaling.

Approaches which he did to handle the slowness:

  1. Vertical Scaling:

    1. Currently his application is running on a single server hosted on some cloud provider (AWS / GCP).

    2. He upgraded the server and bought more RAM, more CPU and more Storage to handle the load.

    3. With the upgrade, performance improved a lot and users were really happy with how fast the application was working.

    4. One day, something bad happened, because of the huge load and lots of users posting threads and videos, server hit the limit and all its storage was full, RAM was full and eventually server got shut down. This led to a very big downtime for the application and all the users were really frustrated because of this.

  2. Horizontal Scaling:

    1. To ensure reliability and availability of the platform, he decided to do horizontal scaling.

    2. He bought more servers from the cloud provider (AWS / GCP) and deployed his application code in all those servers.

      1. Because of this, now there is no single point of failure and even if one application goes down, we have another server which can serve the requests now
    3. Yash setup one load balancer as well, because now we have multiple servers and multiple users who are using the platform. So we need to divide the requests to all the machines, so that there is no high load on a single machine at a given time.

After doing both vertical and horizontal scaling, finally Yash was able to make the platform stable and serve lots of users with good speed.

There are other things involved as well as even after horizontal scaling like load balancing, database replication / sharding, CDNs etc. We will discuss that in coming blogs.

I hope this blog was really helpful and you all learnt something new.

Thank you all for reading this blog. Cheers ๐Ÿป

ย