top of page
Programming

Horizontal vs Vertical Scaling - Which one is better? - System Design

Updated: Dec 8, 2022



Scalability is a well-known problem that is tackled by so many software developers and system architects around the globe. If you are someone who wants to know What is system scaling? Why is system scaling required? Ways to scale a system? Difference between Horizontal and Vertical Scaling? When to use Horizontal and Vertical scaling? - This blog is for you.


Let's dive right in-


Table of contents


1. What is meant by "Scaling a System" or "Scalability"?

Before diving into what is scaling, let's have a look at how a typical system works. It comprises a server having API endpoints exposed for its clients.





Suppose you have a service similar to the one above and you charge users for every request they make. Assume that this service starts becoming popular among users. The number of API requests this server gets starts to increase exponentially. This happens!




There's a limit to the number of requests any server can handle - after all, it's a physical system with limited cores. If the server is flooded with requests above its threshold limit, it will slow down the server, increase the response time of the requests, and can even bring the server down. This means none of the requests will succeed.

As a service provider, you don't want this to happen. You would want that all the requests are served properly. After all, these users are paying you for every request. More request means more profit.


This is where the concept of "Scaling a System" comes in. In software development, Scaling a System refers to the process of upgrading the server configurations to handle much larger loads of traffic and user demands. This "upgrading the server" can happen either by -

  • adding more servers

  • by using a bigger server to fulfill the server requests.


When it comes to scaling a system, there are mainly 2 ways to do it - Horizontal Scaling and Vertical Scaling. Let's have a look at both of them:


2. Vertical Scaling

What is Vertical Scaling?

Upgrading the server by replacing it with a bigger server (with more cores/threads etc.) is called vertical scaling. Having a bigger server means it can handle more requests at a faster speed.






3. Horizontal Scaling

What is Horizontal Scaling?

Upgrading the server by increasing the number of servers to handle more load is called horizontal scaling. By increasing the number of servers, the incoming requests can be distributed randomly across each server, which would mean less pressure on each server, hence the response would be faster.




4. Horizontal Scaling vs Vertical Scaling - The differences


Let's look at some of the differences between horizontal and vertical scaling. Both of these above configurations have their own pros and cons. Interestingly, whatever is the strong point for one configuration is the weakness of the other. Tabulating it for a better perspective.

Horizontal Scaling

Vertical Scaling

Pro: If one of the servers goes down or there is a power outage in one server, the requests can be redirected to the other server. Hence it is Resilient to failures.

Con: There's a single point of failure. All the requests go through this server, hence we can't afford that this server goes down. Hence less available.

Con: Servers will need to communicate over the network for communicating with each other. Hence it is slower.

Pro: Communication happens inside the same system - inter-process communications. Hence this is faster.

Con: A Load Balancer is required to distribute the incoming API requests among the multiple servers. Hence, more resources would be required to set up and maintain the load balancer.

Pro: No such arrangement is required

Pro: Easier to scale since we have the option to add more servers to the system as and when required.

Con: Finite scope of upgradation since there will be a hardware limit to the amount by which the server can be made bigger.

Con: Data consistency can be an issue since we have many servers writing to the same database and probably the same table.

Pro: Data consistency issue won't be present since only one server is going to make changes to the database.

Note: If you want to know more about load balancing, refer to this article -


The important question to address is which option should we choose while building out a large-scale system. There's no one strong answer for it. A hybrid solution which is a mixture of both configurations is a good answer.


5. Which configuration is better? - Horizontal scaling or Vertical Scaling


When an organization is starting out and is small, it will have fewer resources, hence it can go for the vertical scaling option. This way it won't have to deal with configuring/maintaining the load balancer and doesn't have to deal with data consistency issues. When more and more people start using the service and availability starts becoming an issue, then it can start scaling horizontally from that point onward.

In all the arrangements there will be trade-offs. As a software developer, it is your responsibility to take into consideration all these aspects and come up with an intelligent design.


6. Summarising

Scaling a system by increasing the server's size is Vertical Scaling. Increasing the number of servers to handle more load is Horizontal scaling. Vertical Scaling is faster and less complex to set up whereas Horizontal scaling is more available and easily scalable to a great extent.


There's no one right answer on which configuration to use for scaling. Every arrangement comes with its own share of advantages and disadvantages. The important questions to ask are - what is the current server requirement, which arrangement best solves the issue, what are the advantages of the arrangement, and which disadvantages are acceptable to the business needs and which are not? Answering all these questions and coming up with an arrangement of various components is what system design is all about!


7. Frequently Asked Questions (FAQs)

Is Horizontal Scaling better than Vertical Scaling?

As I mentioned the situation makes either horizontal scaling or vertical scaling better. Refer to the above points to decide which configuration will better suit your requirements.

Is Vertical Scaling better than Horizontal Scaling?

Is Horizontal and Vertical Scaling possible in Cloud services like AWS, Azure etc ?



Do let me know in the comments what are your opinions of system scaling and how you proceed with it. Till then, Happy Coding 👋


And that's a wrap! Hi, I am Gourav Dhar, a software developer and I write blogs on Backend Development and System Design. Subscribe to my Newsletter and learn something new every week - https://thegeekyminds.com/subscribe


0 comments

Comments


Related Articles

Categories

Let's Get
Social

  • alt.text.label.Twitter
  • alt.text.label.LinkedIn
  • 25231
Subscribe to our NewsLetter

Join our mailing list to get a notification whenever a new blog is published. Don't worry we will not spam you.

bottom of page