Authors Top

If you have a few years of experience in Computer Science or research, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.


1. Overview

Every engineering team faces the problem of capacity planning when it comes to ensuring that the right resources are in place to handle expected and unexpected traffic demands. Is it better to scale our application (or website) vertically or horizontally when the demand grows?

In this tutorial, we’ll demonstrate how simple it is to grasp this concept. Primarily, we’ll take a look at what scalability means. Then, we’ll go over to explain the difference between vertical and horizontal scaling. Finally, we’ll use an example to show the difference between them.

2. What Is Scalability?

It’s crucial to comprehend what scalability is before debating vertical and horizontal scaling. The quantity of client requests that an application can manage simultaneously is a measure of its scalability. Then, the term “scalability limit” refers to the point at which a hardware resource is exhausted and can no longer serve requests.

Database scalability is the ability of a database to manipulate changing demands by adding and removing data. When the resource’s capacity is reached, the program can no longer handle new requests. Then, the infrastructure can be scaled by administrators by adding more resources, such as RAM, CPU, storage, and network devices, to effectively handle extra demands.

3. Vertical and Horizontal Scaling

The common refrain between vertical and horizontal scaling has been splitting people for a while. While both approaches have advantages and disadvantages, it’s crucial to understand our business needs and match the optimal scaling option with them in order to provide clients with highly available DevOps solutions. Let’s dive into these approaches.

3.1. Horizontal Scaling

What is horizontal scaling? This is the first question that pops up in our minds. So, horizontal scaling (or scaling out), by definition, refers to the practice of adding additional devices to infrastructure in order to enhance capacity and efficiently manage rising traffic needs. Indeed, horizontal scaling, as the name implies, is the process of increasing capacity horizontally by adding additional servers. Then, a load balancer distributes the load and processing power among numerous servers in a system.

3.2. Vertical Scaling

On the other hand, vertical scaling is a sort of scalability in which a machine’s performance is improved by adding additional computing and processing capacity. Besides, vertical scaling (also known as scale-up) helps us to expand the machine’s capacity while keeping resources inside the same logical unit. Therefore, this method improves processing, memory, storage, and network capability. Here’s an example of vertical scaling:

Vertical Scaling

3.3. Difference Between Vertical and Horizontal Scaling

Let’s take a look at the main difference between vertical and horizontal scaling:

Rendered by QuickLaTeX.com

Generally speaking, adding additional machines is considered horizontal scaling, whereas increasing power is considered vertical scaling.

4. Advantages and Disadvantages of Horizontal and Vertical Scaling

Both horizontal and vertical scaling techniques have advantages and disadvantages. Let’s discover the advantages and disadvantages of each vertical and horizontal scaling.

4.1. Horizontal Scaling

Here are some of the advantages of horizontal scaling:

  • It is easy to upgrade
  • It offers flexible, scalable tools
  • Upgrading a horizontally scaled database is easy  (just by adding a node to the server)
  • It is simple to implement and costs less
  • It has limitless scaling with unlimited addition of server instances

Here are some of the disadvantages of horizontal scaling:

  • The cost of the data center will increase significantly because of the power required, the increased space, and the cooling
  • Complex debugging for any bugs in the code
  • The licensing fee is expensive

4.2. Vertical Scaling

Here are some of the advantages of vertical scaling:

  • It is easy to use and implement (we can easily manage the software)
  • The cost of the data center for the power, space, and cooling will be smaller
  • It is a cost-efficient software
  • The resources for this approach are flexible

Here are some of the disadvantages of vertical scaling:

  • There is a limit to the amount we can upgrade
  • The hardware costs more because high-end servers
  • Restriction to a single database vendor and migration is challenging (we may need to start over)
  • The cost may be low, but we’ll need to pay for a license each time we scale up

Let’s sum up the advantages and disadvantages of the two approaches:

Rendered by QuickLaTeX.com

A single application can use both vertical and horizontal scaling approaches, with certain elements of the program scaling up while others scale out.

5. Example: Web Application

In this section, we’ll give a quite simple example of a web application. Take into account a straightforward web application design where a web server linked to a database server hosts the application. Hence, the web server responds to client requests, speaks with the database server, sends the necessary data, or carries out a job in response to a client request.

5.1. Vertical Scaling

While maintaining the current architecture, vertical scaling upgrades the CPU, RAM, and storage resources. Therefore, we can upgrade the web server’s settings as the traffic increases. We can only make a certain number of enhancements, though. As a matter of fact, performance might deteriorate over time if the web server is handling thousands of client requests on its own.

This scaling approach still has a single point of failure. If something goes wrong with the server, our application will crash because there is no redundancy or backup option.

5.2. Horizontal Scaling

On the other hand, we can scale horizontally by increasing the number of servers in the infrastructure to accommodate thousands of concurrent requests. As a result, the traffic is divided across several servers by a load balancer. The load balancer uses routing techniques like Round Robin to direct traffic to the available servers based on the IP addresses of the clients.

Having only one load balancer brings up the issue of a single point of failure once more. To address this issue, we install two or three load balancers, with one actively directing traffic and the others serving as backups.

5.3. Session Storage

For instance, the load balancer may direct a client to server {1} when they visit the website, and server {1} would then store the client’s session. Then, the client may log in at any time through server {1}. On the next request, the user/client may be routed to server {2}where they may log in again because this server does not contain the session information.

To remedy the issue, session information can be detached and stored in a different location, such as an in-memory data structure store, like a Redis server. Here’s an example in which all servers send and receive all their sessions to and from the Redis server:

Session Storage

Once again, the Redis server has the potential to be a single point of failure. Therefore, we’ll need to give the Redis server redundancy to strengthen the robustness of our service and avoid this potential issue.

6. Conclusion

In this tutorial, we’ve discussed the basic concept of scalability by using an example to distinguish the vertical and horizontal scaling of a computing system. At first, we explored scalability and its characteristics. Then, we reviewed and compared vertical scalability and horizontal scalability in a summarized way. Finally, we used a web application as an example to unlock its mechanism.

We can conclude that both vertical scaling and horizontal scaling are unquestionably beneficial to computing systems.

Authors Bottom

If you have a few years of experience in Computer Science or research, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

Comments are closed on this article!