System Design: Horizontal and Vertical Scaling

System Design: Horizontal and Vertical Scaling

Introduction

Ninja recently completed the Android App Development Course from Coding Ninjas. To impress his friend Nina, he decided to develop a chatting app. Because of the extensive knowledge, he gained from the course, he was able to develop the app in just a few days. Nina was quite impressed with the app, which she then showed to all her friends.

Ninja’s app was becoming increasingly popular, and the number of users was rapidly growing. On the other hand, Ninja’s app was not designed to handle such a high volume of traffic. So, in that situation, his app might stop functioning.

What do you think Ninja would have done in that situation?

The solution to this problem is scalability.

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 react rapidly with the most up-to-date information.

Scalability is also one of the most important questions asked in a system design interview. In this blog, we will discuss horizontal and vertical scaling which are two different scalability techniques.

What is Scalability?

Scalability is sometimes mistakenly used synonymously with growth. However, meeting demand is the actual definition of scalability. 

Scalability, from a business standpoint, is the ability to serve clients effortlessly even when demand changes abruptly.

From an IT perspective, scalability is the ability to add/remove infrastructure resources required by business applications to accommodate increased/decreased demand in the number of business transactions.

The number of requests that an application can efficiently support concurrently can be used to determine its scalability. The point at which no more requests can be successfully handled by an application is its scalability limit.

This limit is reached when a vital hardware resource runs out, necessitating the use of different or additional machines. Scaling these resources can entail any combination of CPU and physical memory, hard drive, and/or network bandwidth modifications.

Scaling is the process of expanding resources and performance with increasing load and traffic on an existing system without increasing complexity.

Scalability is a critical feature of enterprise software. Prioritising it from the beginning results in fewer maintenance costs, a better user experience, and more agility.

Types of Scaling

There are two ways to scale a system:

  1. Vertical Scaling
  2. Horizontal Scaling

Let us discuss both of them one by one.

Vertical Scaling

Source: Dzone

Vertical scaling expands a system’s scalability by adding more power to an existing machine. In other words, vertical scaling refers to improving an application’s capability via increasing hardware capacity.

This is why it’s called vertical: we add additional CPU, memory, and disc space, but the app’s and infrastructure’s design remains unchanged. It can boost the performance of the server without modifying the code. However, it is constrained by the fact that there is a limit of hardware we can add.

Vertical scaling is also known as scaling up, which refers to increasing the power and capacity of a single resource.

Cloud architects may now achieve AWS vertical scaling and Microsoft Azure vertical scaling by adjusting instance sizes. Because AWS and Azure cloud services offer various instance sizes, vertical scaling in cloud computing is possible for everything from EC2 instances to RDS databases.

MySQL and Amazon RDS are two examples of vertical scaling.

Pros for Vertical Scaling

  • Easy to implement.
  • Does not require partitioning of data.
  • Less administrative effort.
  • Reduced software costs.
  • Consumes less power.
  • Application compatibility is maintained.

Cons for Vertical Scaling

  • Risk of high downtime.
  • Greater risk of hardware failures and outages.
  • Future upgradeability has a limited scope.
  • Expensive implementation cost.
Source: Dzone

Horizontal Scaling

Horizontal scaling expands a system’s scale by adding more machines. It improves the performance of the server node by adding more instances of the server to the existing pool of servers, allowing the load to be distributed more evenly.

It does not change the capacity of the individual server, but it does reduce the load on the server. It is achieved by the use of a distributed file system, load balancing, and clustering.

Horizontal scaling is also known as scaling out, which refers to increasing the amount of provisioned resources.

Businesses adopt horizontal scaling for various reasons, including increased I/O concurrency, the need to lessen the load on current nodes, and the expansion of disc space. Many major web service providers, like Google with Gmail and YouTube, Facebook, Amazon, Yahoo, eBay, and others, make extensive use of horizontal scaling.

Cassandra, MongoDB, and Google Cloud Spanner are good examples of horizontal scaling. 

Pros for Horizontal Scaling

  • Lower downtime compared to vertical scaling.
  • Easy to upgrade in the future.
  • Easier to run fault tolerance.
  • More efficient utilization of smaller systems.
  • Enhanced resilience as a result of the presence of separate, multiple systems.

Cons for Horizontal Scaling

  • Highly complicated architectural design.
  • Require partitioning of data.
  • Greater footprint and impact on the data center.
  • Additional networking equipment, such as switches and routers, is required.
  • High utility costs in terms of cooling and electricity.

Vertical Scaling vs Horizontal Scaling: A Quick Comparison

We now have a clear understanding of horizontal and vertical scaling, as well as their pros and cons. Let us now compare them on several parameters:

Vertical ScalingHorizontal Scaling
DatabasesThe data is stored on a single node, and scalability is achieved by multi-core, for example, by distributing the load among the machine’s CPU and RAM resources.Horizontal scaling is typically based on data partitioning (each node only contains a part of the data).
Load BalancingLoad balancing is not required as the data is stored on a single node.Horizontal scaling necessitates load balancing to spread or distribute traffic to different machines.
Down TimeVertical scaling is limited to a single machine’s capacity; scaling beyond that capacity may increase downtime.By 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 ConsistencyVertical scaling uses a single machine to which all queries are forwarded, eliminating the possibility of data inconsistency.Data is inconsistent in horizontal scaling because separate machines process different requests, which might cause their data to become out of sync.
Failure ResilienceBecause of a single machine, it has a single point of failure. Thus, vertical scaling is not failure resilient.Less prone to system failure. If one of the machines fails, we can reroute the request to another, and the application will not be affected.
Machine CommunicationVertical scaling relies on quick inter-process communication.Horizontal scaling necessitates machine-to-machine network communication or calls. Network calls are slower and prone to fail.

The Decision to Scale Vertically or Horizontally

Now, you’re probably wondering about horizontal and vertical scaling, which is best for a particular application. We can see that horizontal and vertical scaling both have advantages and disadvantages.

There will always be some trade-offs thus, deciding which one is best for an application may be more difficult. Let us consider some factors which can help you decide to choose between the two.

  1. Performance: Horizontal scaling enables you to combine the power of several machines into a single virtual machine with the sum of their power. This means you’re not restricted to a single unit’s capacity. But first, determine whether you have enough resources within a single system to meet your scalability requirements.
  1. Redundancy: Horizontal scaling provides built-in redundancy as opposed to vertical scaling, which has only one system and thus a single point of failure.
  1. Flexibility: If your system is only intended for vertical scaling, you are virtually tied to a minimum price specified by the hardware. Horizontal scaling may be a preferable alternative if you want the flexibility to choose the ideal configuration setup at any moment to maximize cost and performance.
  1. Regularity of Upgrades: Again, flexibility is essential here. Building an application as a single huge unit makes it more difficult to add or update specific sections of code without crashing the entire system. It is easy to decouple and horizontally scale your application to provide a more continuous upgrade process.
  1. Geographical Distribution: When you need to spread your application across geographical areas or data centers to reduce geo-latency, comply with regulatory standards, or handle disaster recovery scenarios, you might not have the option of installing your application in a single box. You must distribute it.
  1. Cost: As increasingly massive multi-core computers become available at considerably reduced prices, consider whether your application (or portions of your application) may be productively bundled in a single box while still meeting your performance and scalability goals. This could result in cost savings.

In conclusion, choosing between horizontal and vertical scaling isn’t always a good idea. Moving between the two models is sometimes a better option.

So, when it comes to scaling in a microservices architecture, there are many more things to consider than scalability. However, combining a micro-services architecture with horizontal scalability often yields more excellent capacity elasticity than a monolithic architecture.

The industry is anticipated to shift more toward a horizontally distributed strategy to scaling architecture. The need for increased reliability is driving this trend through a redundancy plan and the need for greater utilization through resource sharing as a result of cloud/SaaS migration.

Combining horizontal and vertical scaling together, on the other hand, allows us to benefit from both paradigms.

Frequently Asked Questions

What is scaling in system design?

Scaling is the process of expanding resources and performance with increasing load and traffic on an existing system without increasing complexity. Horizontal and vertical scaling are two types of scaling methods.

What is vertical scaling?

Vertical scaling refers to enhancing an application’s capability by increasing hardware capacity. We add more CPU, memory, and disc space in vertical scaling, but the application and infrastructure remain the same. Vertical scaling is also known as scaling up, which refers to increasing the power and capacity of a single resource.

What is system scaling?

System scaling is a technique of scaling an application to satisfy user demand at any moment. It is commonly referred to as scalability, which means the ability of an application to add or remove infrastructure resources when demand for business transactions increases or decreases.

What is an example of scaling vertically?

The latest edition of AWS Ops Automator enables vertical scaling of Amazon EC2 instances, allowing automatic management of resources.

It automatically adjusts capacity in order to ensure consistent, predictable performance at the lowest possible cost.
It can resize the instances by restarting the existing instance with a new size. Alternatively, it can resize an instance by replacing the old instance with a new, resized instance.

Is vertical scaling better than horizontal scaling?

We’ve seen that both horizontal and vertical scaling have pros and cons. One may be the finest for one application but maybe the worst for another. Which scale is better is determined by several factors.

However, in a business application, horizontal scaling is more desirable.

Key Takeaways

With this discussion, this blog attempted to deep dive into horizontal and vertical scaling, its different types, advantages, disadvantages, and essential factors that one should consider while choosing between vertical and horizontal scaling.

Consider checking out the Guided Path of System Design to learn more useful concepts and crack your interviews like a Ninja!

We hope you found this blog useful. Feel free to let us know your thoughts in the comments section.

Exit mobile version