Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: October 17, 2025
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.
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.
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.
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.
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:
Let’s take a look at the main difference between vertical and horizontal scaling:
| Vertical Scaling | Horizontal Scaling |
|---|---|
| Increases the server’s hardware configuration without changing the logical unit. | The number of instances may be expanded without raising the hardware requirements. |
| The logic is the same when it comes to vertical scaling. The identical code is run on a computer with more processing power. On the device processor’s many cores, concurrent programming is carried out using multi-threading. | The sequential piece of logic is divided into smaller chunks and carried out concurrently across several devices. |
| Amazon RDS and MySQL are typically employed. | Using patterns like MapReduce and Tuple Spaces, administrators divide jobs among several networked workstations. This approach of data management makes use of MongoDB, Cassandra. |
Generally speaking, adding additional machines is considered horizontal scaling, whereas increasing power is considered 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.
Here are some of the advantages of horizontal scaling:
Here are some of the disadvantages of horizontal scaling:
Here are some of the advantages of vertical scaling:
Here are some of the disadvantages of vertical scaling:
Let’s sum up the advantages and disadvantages of the two approaches:
| Vertical Scaling | Horizontal Scaling | |
|---|---|---|
| Data | Data is executed on a single node | Data is partitioned and executed on multiple nodes |
| Data Management | Easy to manage (share data reference) | Complex task as there is no shared address space |
| Downtime | Downtime while upgrading the machine | No downtime |
| Upper limit | Limited by machine specifications | Not limited by machine specifications |
| Cost | Lower licensing fee | Higher licensing fee |
A single application can use both vertical and horizontal scaling approaches, with certain elements of the program scaling up while others scale out.
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.
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.
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.
For instance, the load balancer may direct a client to server when they visit the website, and server
would then store the client’s session. Then, the client may log in at any time through server
. On the next request, the user/client may be routed to server
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:
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.
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.