Horizontal vs. Vertical Scaling – How to Scale a Database (2024)

/ #Database
Horizontal vs. Vertical Scaling – How to Scale a Database (1)
Sophia Iroegbu
Horizontal vs. Vertical Scaling – How to Scale a Database (2)

Data Scalability

Data scalability refers to the ability of a database to manipulate changing demands by adding and removing data. In this way, the database grows at the same pace as the software.

Via scaling, the database can expand or contract the capacity of the system's resources to support the application's frequently changing usage.

There are two ways a database can be scaled:

  • Horizontal scaling (scale-out)
  • Vertical scaling (scale-up)

In this article, we'll look at both methods of scaling and discuss the advantages and disadvantages of each to help you choose.

Horizontal Scaling

This scaling approach adds more database nodes to handle the increased workload. It decreases the load on the server rather than expanding the individual servers.

When you need more capacity, you can add more servers to the cluster. Another name for this scaling method is Scaling out.

Horizontal vs. Vertical Scaling – How to Scale a Database (3)

Advantages of Horizontal Scaling:

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

Disadvantages of Horizontal Scaling:

  • Any bugs in the code will become more complex to debug and understand
  • The licensing fee is expensive as you will have more nodes that are licensed
  • The cost of the data center will increase significantly because of the increased space, cooling, and power required

When to use horizontal scaling:

If you are dealing with more than a thousand users, it is best to use this scaling system because when the servers receive multiple user requests, everything will scale well.

It will also not crash because there are multiple servers.

Vertical Scaling

The vertical scaling approach increases the capacity of a single machine by increasing the resources in the same logical server. This involves adding resources like memory, storage, and processing power to existing software, enhancing its performance.

This is the traditional method of scaling a database. Another name for this approach is Scale-up.

Horizontal vs. Vertical Scaling – How to Scale a Database (4)

Advantages of Vertical Scaling:

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

Disadvantages of Vertical Scaling:

  • The cost may be low, but you will need to pay for a license each time you scale up
  • The hardware costs more because of high-end servers
  • There is a limit to the amount you can upgrade
  • You are restricted to a single database vendor, and migration is challenging, or you may need to start over

When to use vertical scaling:

The vertical scaling approach is for you if you need a system with unique data consistency.

If you don't want to worry about balancing the server's workload, vertical scaling is the best option.

Differences Between Vertical and Horizontal Scaling

VerticalHorizontal
The license costs lessThe license costs more
This method increases the power of the server with additional individual serversThis method increases the power of the server with the existing server
This data is present on one single node, and it is scaled through a multicoreThis is based on partitioning each node that contains a single part of data

Which scaling method is best for your app?

When choosing how to scale your database, you must consider what's at stake when you scale up and out.

Now we'll take a look at some factors to consider so you can choose which scaling system is best for your app:

Load balancing

The vertical scaling system is best for balancing loads because you have a single server (vertical scaling), and there is no need to balance your load. Horizontal scaling requires you to balance the workload evenly.

Point of failure

The horizontal scaling system has more than one server, so when one server crashes, the next one picks up the slack. This means that there is no single point of failure which makes the system resilient.

But in the vertical scaling system, there is only one server, so once the server crashes, everything goes offline.

Speed

In terms of speed, the vertical scaling system is faster because, since it runs on one server, the vertical scaling system has an interprocess communication – that is, the server communicates within itself and it's fast.

The horizontal scaling system has network calls between two or more servers. This is also known as Remote Procedure Calls (RPC). RPCs are slow, though.

Data consistency

When dealing with servers, you'll need to make sure that the data stored in them is consistent when end users send a request.

The vertical scaling system is data consistent because all information is on a single server. But the horizontal scaling system is scaled out with multiple servers, so data consistency can be a huge issue.

Hardware limitations

The horizontal scaling system scales well because the number of servers you throw at a request is linear to the number of users in the database or server. The vertical scaling system, on the other hand, has a limitation because everything runs on a single server.

When choosing a system to scale your database, make sure to make a pros and cons list of the information in this article. It will help you decide which to use.

Conclusion

A cloud computing model's scalability is the ability to quickly and instantly increase or decrease an IT capacity. Knowing how the two types of scaling work is crucial as this plays a massive role in your database or server management.

Quick recap...

  • A server's role is to enhance its capacity to handle the increased workload, called Vertical scaling.
  • A system's job is to add new nodes to manage the distributed workload, termed Horizontal scaling.
  • The horizontal scaling system scales well as the number of users increases.
  • The vertical scaling system is faster due to its ability to inter-process communication.

Thanks for reading!

ADVERTIsem*nT

ADVERTIsem*nT

ADVERTIsem*nT

ADVERTIsem*nT

Horizontal vs. Vertical Scaling – How to Scale a Database (5)
Sophia Iroegbu

I’m a Backend Engineer & Technical writer that writes about Backend engineering topics.

If you read this far, thank the author to show them you care.

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

ADVERTIsem*nT

Horizontal vs. Vertical Scaling – How to Scale a Database (2024)

FAQs

Horizontal vs. Vertical Scaling – How to Scale a Database? ›

While horizontal scaling refers to adding additional nodes, vertical scaling describes adding more power to your current machines. For instance, if your server requires more processing power, vertical scaling would mean upgrading the CPUs. You can also vertically scale the memory, storage, or network speed.

How do you horizontally scale a database? ›

The sharding method of horizontal scaling involves dividing a large database into smaller, more manageable pieces (called shards) and then distributing the shards across multiple machines.

How can a database be scaled vertically? ›

The vertical scaling approach increases the capacity of a single machine by increasing the resources in the same logical server. This involves adding resources like memory, storage, and processing power to existing software, enhancing its performance. This is the traditional method of scaling a database.

How do you scale up a database? ›

There are two commonly used horizontal database scaling techniques: replication and horizontal partitioning (or sharding). MongoDB is a modern, document-based database that supports both of these.

How do you choose vertical and horizontal scalability? ›

10 factors for choosing between horizontal vs vertical scaling
  1. Traffic patterns. Observe how demand fluctuates. ...
  2. Resource efficiency. Assess resource optimization needs. ...
  3. Cost considerations. ...
  4. Application architecture. ...
  5. Downtime tolerance. ...
  6. Future growth forecast. ...
  7. Cloud service integration. ...
  8. Operational simplicity.

Does SQL scale horizontally or vertically? ›

They excel in handling complex queries, enforcing data integrity, and providing a structured schema for data. SQL databases are traditionally scaled vertically by enhancing the hardware capabilities of the server they run on.

Why can't SQL database scale horizontally? ›

In a horizontally scaled SQL database, one of the most significant challenges is maintaining consistency across all nodes. Consistency, in this context, means that each node in the distributed system should reflect the same data state.

What are the rules for horizontal scaling? ›

Horizontal scaling can be done by multiplying the input with a constant. The graph stretches if the value of C < 1, and the graph will shink if the value of C > 1. We can see that the distance of the points on the curve gets closer to the y-axis.

How do I scale a MySQL database horizontally? ›

Mysql Horizontal Scaling Strategies. Horizontal scaling can be achieved via read replicas. Horizontal scaling involves spreading data and workload across multiple servers, which can significantly improve MySQL performance. This can be achieved through sharding, partitioning, and read replicas.

What is an example of horizontal scaling? ›

Horizontal scaling is the process of adding a resource to a set or cluster of resources. An example would be adding a virtual machine to a cluster of virtual machine clusters or adding a database to a database cluster.

Can we scale SQL database? ›

You can easily scale out databases in Azure SQL Database using the Elastic Database tools. These tools and features let you use the database resources of Azure SQL Database to create solutions for transactional workloads, and especially Software as a Service (SaaS) applications.

Which database is best for horizontal scaling? ›

NoSQL databases are inherently more scalable than relational databases because you can scale them both vertically and horizontally. And they have a distributed architecture designed to handle large volumes of data across multiple servers.

What does it mean to scale-up a database? ›

Vertical scaling, or scaling up or down, where you increase or decrease computing power or databases as needed—either by changing performance levels or by using elastic database pools to automatically adjust to your workload demands.

Which is better horizontal or vertical scaling? ›

Your choice should align with your business goals and ensure the smooth operation of your applications or websites. Horizontal scaling is a good choice when you need to handle high traffic volumes, while vertical scaling is more suitable for complex tasks that require greater processing power.

What is an example of vertical scaling? ›

Vertical scaling (or "scaling up") refers to adding more hardware to an existing machine so that you run the same workload on better specs. For example, if a server requires more processing power, vertically scaling the device would mean upgrading its CPU.

What are the problems with horizontal scaling? ›

Scaling horizontally involves deploying multiple instances of an application, which can lead to data inconsistency issues. Coordinating data updates across these instances becomes complex.

Can we scale RDS horizontally? ›

Scaling in RDS

You can scale both horizontally and vertically in RDS, with Read Replicas being an example of horizontal scaling. Let's talk about how to enable Read Replicas, and how to promote a Read Replica to a master standby instance.

What is the formula for horizontal scaling? ›

What is horizontal scaling in the graph? In equation y = f ( k x ) If the magnitude of k is greater than 1, then the graph will compress horizontally, but if the magnitude of k is less than 1, then the graph will stretch out horizontally.

How is horizontal scaling achieved? ›

Horizontal scaling is the ability for an application to automatically scale by adding/reducing computing nodes as the workload increases/decreases. This is in contrast to vertical scaling, which means that you scale by adding more power (CPU, RAM) to an existing machine.

Top Articles
Latest Posts
Article information

Author: Lilliana Bartoletti

Last Updated:

Views: 6035

Rating: 4.2 / 5 (73 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Lilliana Bartoletti

Birthday: 1999-11-18

Address: 58866 Tricia Spurs, North Melvinberg, HI 91346-3774

Phone: +50616620367928

Job: Real-Estate Liaison

Hobby: Graffiti, Astronomy, Handball, Magic, Origami, Fashion, Foreign language learning

Introduction: My name is Lilliana Bartoletti, I am a adventurous, pleasant, shiny, beautiful, handsome, zealous, tasty person who loves writing and wants to share my knowledge and understanding with you.