DEV Community

Prakash Singh
Prakash Singh

Posted on

System Design : Vertical And Horizontal Scaling

To expose our code, we cannot simply give our computer to anyone. Therefore, we need to find a way to share our code securely. To run our code, we first need to create a database on our computer and also plan for contingencies in case of power loss. It's crucial to ensure that our service remains uninterrupted since many people depend on it, and we don't want to disappoint them.

To achieve this, we should consider hosting our services on the cloud.

But what distinguishes cloud computing from desktop computing? There's actually no significant difference between the two. With cloud computing, we can access a set of computers that provide computational power, just like a desktop that's located somewhere else. We can upload our code to a cloud computer via remote login, making cloud computing a viable option for running our services.



Let's focus on the business requirements.

If many people will be using your service and your code can't handle that many requests, what will be the solution? There are two approaches:

  1. Vertical Scaling: You can upgrade your existing machine to a larger one to process requests faster.
  2. Horizontal Scaling: You can add more machines and distribute requests among them. Both of these approaches are known as scalability, which is the ability to handle an increasing number of requests. By implementing these mechanisms, you can increase the scalability of your system.



Horizontal Scaling

  • [1], [2], [3], [4], [5]. (Many Different Machines)
  • Load Balancing Required
  • Resilient : Request can be redirected if system is busy.
  • Communication between servers occurs over the network, which means that it involves network calls. However, network calls are generally slower than other types of calls since they involve input/output (I/O) operations. This is because data needs to be transmitted over the network, which takes time. Such calls are also known as Remote Procedure Calls (RPC).
  • Data inconsistency can occur when multiple requests are simultaneously using the database.
  • Scales well as users increase.



Vertical Scaling

  • [ Huge Machine ]
  • No Load Balancing Required
  • Single point of failure. Because of only one machine.
  • Here we have Inter Process Communication. So faster than Horizontal Scaling.
  • Data consistent because one system where all data resides.
  • Hardware Limit.



What do you think is used in the real world?

  • The answer is that both vertical and horizontal scaling have different benefits, so we use them according to our requirements.
  • However, a hybrid solution is essentially horizontal scaling, where each machine has a larger processing capacity.
  • Initially, it's recommended to use vertical scaling, but once users trust your service, you can consider moving to horizontal scaling.

Top comments (1)

Collapse
 
ant_f_dev profile image
Anthony Fung

Great overview! It's worth noting that it's possible to get data inconsistency with vertical scaling too. On systems that can handle concurrent requests, it's equally possible to have more than one process that tries to access a database.

However, it's easier to put a concurrency lock in place (if that's really what you want to do) on a single vertically scaled system.