Horizontal vs. Vertical Scaling - What, Which, and When?
Tags: database, serverless, cloud, devjournal
Published: 2022-11-08 15:20:57

If you want to market your software product, having the most promising app is not the end goal. Rather, you should focus on scaling the app as you go. Usually, people think of scalability in terms of performance, but they tend to forget that database scaling is also equally crucial. There are two ways to do database scaling. Horizontal scaling and Vertical scaling. Let’s know about them in brief and why you should stick with a particular scaling type.

##What is Vertical Scaling?

One of the easiest ways to scale a database is by doing vertical scaling. Vertical scaling means adding more resources to the existing server in order to increase its load-handling capacity. You can add resources like CPU, hard disks, and RAMs. This is a very primitive way of scaling the database.

###Advantages 

- **Vertical scaling is cost-effective:** You don’t need to invest in the new server. All you need to do is upgrade or add to the existing server. Maintenance cost is also comparatively low in this case.
- **Less complex process communication:** When you don’t have multiple servers handling the load, there is no need for synchronization with other machines. This results in quick responses. 

###Disadvantages

- **Single point of failure:** As all of your operations are on a single server, in case of a hardware failure - you will be like a sitting duck.
- **Higher possibility of downtime:** If you are not planning to use a backup server, you will be witnessed a lot of downtimes while upgrading your server.

##What is Horizontal scaling?

Horizontal scaling means adding more servers parallel to the existing one for equal-load distribution. Horizontal scaling is a more tedious and time-consuming process than vertical scaling. However, using horizontal scaling, one can scale indefinitely by leveraging clustering and load-balancing techniques. 

###Advantages 

- **Increased fault tolerance:** In horizontal scaling, you are not dependent only on one node for all your data and operations needs. Distributed data amongst several nodes save you from complete data loss. 
- **Scaling is easier from a hardware perspective:** Unlike vertical scaling, where you need to check hardware compatibility for upgrades, there is no such need for horizontal scaling. All you need to do is add additional machines to your current pool.

###Disadvantages 

- **Increased initial cost:** It is obvious that paying for RAM, storage, and CPUs is far cheaper than paying for an entire system.
- **Increased complexity for maintenance:** There is always a struggle while maintaining multiple servers than one single server. One needs to make sure that every node is performing in a synchronous fashion with one another. 

##Which data scaling option should you choose?

As we have seen, both horizontal and vertical scaling have their own sets of advantages and disadvantages. There really isn’t a one-fit-for-all solution to the question. However, there are a few factors you need to consider before picking up your [desired database scaling solution](https://www.simform.com/blog/bottlenecks-of-scaling-database-how-to-solve/).

- The initial cost of scaling
- Future-proof scalability solution
- Performance and complexity
- Ease of maintenance
- Downtime and reliability

##When to use Horizontal/Vertical scaling?

Horizontal Scaling - If you are sure that in the future, you will be dealing with more than 1000 users. It is recommended to use horizontal scaling in this situation. As you are expecting to receive multiple user requests, horizontal scaling can handle the requests by load balancing without breaking a sweat. System crashes will be minimal in this situation. 

Vertical Scaling - If you are expecting fewer loads, hassle-free maintenance, and unique data consistency, vertical scaling is the way to go. It is also the most affordable type of data scaling. However, being a single node, you might have to deal with downtime and crashes if there is a surge of traffic.