Home System Design Tutorial Horizontal Scaling and Vertical Scaling

Horizontal Scaling and Vertical Scaling

When developing a system, scalability is a critical factor to consider. Any application at the enterprise level must be able to handle a large number of requests at once and respond rapidly with the latest information.

Scaling is the ability of a system to grow or shrink in size to meet the increasing user requirement. A scalable system has an advantage because it is adaptable to the changing needs or demands of its users. Scaling can be achieved either by adding more resources to the current system, by adding new systems to the existing one, or by both.

Scalability is a critical feature to consider while designing any enterprise software. Prioritizing it from the beginning will result in lesser maintenance costs, better user experience, and more availability. Also, if you are aiming to get into a big tech giant company then you should know this concept very well.

Types Of Scaling

When we are talking about System Design, we generally talk about two types of Scaling:

  1. Vertical Scaling
  2. Horizontal Scaling

Both Horizontal and vertical scaling involve adding computing resources to your infrastructure but the differences lie in terms of implementation and performance.

Horizontal-and-vertical-scaling
Horizontal and Vertical scaling

1. Vertical Scaling

In vertical scaling, we add more new resources to the same system i.e, increase the amount of RAM, CPU, GPU, and other resources to meet the increased computing requirement. It is easy to accomplish. It also consumes less power.

But, Vertical Scaling does not make the system fault-tolerant, i.e if we are scaling applications running with a single server and if that server goes down, our entire system will go down. Also, it is often limited to a single machine i.e, scaling beyond that machine’s capacity often involves downtime.

Advantages:
  1. Ease of implementation.
  2. Less Power consumption
  3. Faster and less complex communication.
  4. Less administrative effort.
  5. Data partitioning is not required.
Disadvantages:
  1. Risk of increased downtime.
  2. Single point failure.
  3. Limited scaling and upgrade limitation.

2. Horizontal Scaling

In Horizontal Scaling, we scale by adding more systems to the existing pool of systems. Since all server works independently and is equally capable of handling the request, hence this will eventually decrease the load of requests on each server and also make the entire system fault-tolerant i.e, even if one server goes down other systems will handle the upcoming request. Also, there is no limit, we can add as many new servers as we want.

The challenge with Horizontal Scaling is it is hard to implement as it requires all of the systems to be synchronized with each other also, we need to use a load balancer to distribute the load equally among all systems, which is an additional overhead.

Advantages
  1. Lesser downtime.
  2. Easy to upgrade in the future.
  3. Increased resilience and fault tolerance.
  4. Increased performance.
Disadvantages
  1. Increased complexity.
  2. Increased initial cost.
  3. Complicated architectural design.
  4. Requires extra networking equipment.

Comparison between Horizontal and Vertical Scaling

Now we know the difference between Horizontal and Vertical scaling, let’s compare both approaches based on several parameters:

Vertical ScalingHorizontal Scaling
DatabaseData is stored in a single node and scaling is achieved by multicoreIn Horizontal scaling, the data is partitioned among several nodes.
Load BalancingLoad Balancing is not required as data is stored only on a single node.Load Balancing is required as data is distributed among several nodes.
Failure ResistanceIt has a single-point failure as there is only a single node.It is less prone to system failure as if one node fails, we can reroute the request to another, and the application will not be affected.
DowntimeAdding more resources to a single machine beyond its capacity can increase downtimeBy adding more machines to the existing pool, we are no longer limited to the capacity of a single unit, allowing us to scale with less downtime.
Data ConsistencyAdding more resources to a single machine beyond its capacity can increase downtimeBy adding more machines to the existing pool, we are no longer limited to the capacity of a single unit, allowing us to scale with less downtime.
CommunicationThey rely on interprocess communication hence the communication is faster.They rely on network calls between several nodes and hence are slower and prone to failure.

 

Which scaling approach is right for your application?

After understanding both Horizontal and Vertical scaling we know each scaling approach has its advantages and disadvantages and there will always be some trade-off with each approach hence it might be difficult to decide which one is right for your application. Let’s talk about factors that can help in making the right choice:

  1. Performance: Horizontal scaling can increase the performance of your application as it allows you to combine the capabilities of several machines into a single virtual machine. But with vertical scaling, you need to
  2. Redundancy: The way horizontal scaling provides a built-in redundancy feature, as opposed to vertical scaling which has only one machine, and hence redundancy is not possible.
  3. Geographical Distribution: When the requirement is to distribute data across various data centers, located worldwide and handle disaster recovery then horizontal scaling is the only option.
  4. Cost: Upgrading an existing server resources costs less than purchasing a new one. Hence the cost of Horizontal scaling is more than Vertical scaling. Additionally, you are less likely to add new backup and virtualization software when scaling vertically moreover the maintenance costs may potentially remain the same too.

Now we have seen the advantages and disadvantages of both horizontal and vertical scaling, we can’t simply say that one approach of scaling is better than the other. It boils down to what your application requirements are. Still, when making the right scaling decision you should consider the following factors. If your goal is to accomplish superior performance, you can use either vertical scaling or horizontal scaling, or both in a cloud environment.

LEAVE A REPLY

Please enter your comment!
Please enter your name here