Horizontal vs. Vertical Scaling: Which Is Best for APIs? (2024)

Key Takeaways

Horizontal scaling adds more machines to a system, distributing the load. Vertical scaling upgrades a single machine’s CPU, RAM, and storage. The choice depends on system architecture and application needs.

Demand for an application programming interface (API) is usually not static. It will go up and down over time. In certain cases, such as holiday season spikes in traffic, an API might need to handle a significantly higher volume of requests than it does at other times. To meet such an increase in traffic, it is necessary to scale up the API. System admins have two choices when it comes to scaling an API. They can go with horizontal scaling, which refers to adding more API instances to a cluster, or vertical scaling, which means adding to the computing capacity of the machine that supports the API. This article explores the differences between the two and which one is best for API scalability.

Horizontal scaling

Horizontal scaling, also known as “scaling out,” is the process of deploying additional virtual machines (VMs) so there will be more API capacity to handle an increased load. (Shrinking capacity is known as “scaling in.”) As more capacity is needed, system admins can add more VMs to the cluster. Specialized resource management software is required, however, to manage the load of API calls and route them to the right VM instance in the cluster and maintain balance.

Vertical scaling

Vertical scaling is the process of adding resources to a single node. It stands in contrast to horizontal scaling, which adds nodes. Vertical scaling, also called scaling up or scaling down, means adding resources such as central processing unit (CPU) capacity, memory, or storage to a server. In the case of APIs, vertical scaling usually involves adding computing capacity to the VM that hosts the API.

For example, if an API is hosted on a VM that’s been allocated one CPU core and 512 megabytes of random access memory (RAM), then scaling that API up could mean doubling the core count and RAM. The API would then have two dedicated CPU processor cores and 1024 megabytes of RAM. With this new configuration, the API should be able to handle roughly double the load—though constraints on network bandwidth, storage speed, and other factors may reduce the impact of vertical scaling. There is also a resource management challenge with vertical scaling, but specialized software can typically handle this issue.

Why APIs statelessness matters for scaling

Which method of scaling is better for APIs? To answer that, it’s first necessary to understand the impact of an API’s stateless architecture. To do that, let’s briefly discuss the difference between stateless and stateful applications. A stateful application stores data from one request to the next. It keeps track of requests and uses the data later. For instance, a stateful app might save information about a client in local memory. This might occur for the purpose of session management or security.

There is nothing wrong with being stateful. Indeed, it may be essential to the desired functioning of the app. However, it is significantly more complicated to execute horizontal scaling for a stateful app. Doing so would require copying stored data from the original version of the app to new instances.

A stateless app or API, in contrast, is one that does not store request data. It does not hold onto session data in memory. Each time a session starts, it’s as if the app is meeting the client for the first time. After the session is over, it’s “goodbye,” with no memory of the session.

Horizontal scaling is possible for a stateless app because it doesn’t matter which VM is responding to API calls. The API client can call on an infinite number of VMs hosting the API, and it will never matter. System admins can add or remove as many VMs as they want without affecting the operation of the API.

Horizontal scaling, the right choice for APIs

Given that APIs are stateless, horizontal scaling emerges as the right way to scale them. Adding more VMs to increase capacity works well with stateless APIs. Admins can create VM clusters that scale out as API demand grows.

Furthermore, while it is possible to scale APIs vertically, horizontal scaling is preferable because the resource allocation issues in vertical scaling make it comparatively harder to do. In contrast, horizontal auto-scaling works easily with APIs. As systems management tools detect a spike in API traffic, they can automatically add VMs to host more instances of the API in a cluster. This is quite a bit more difficult in a vertical scaling situation, as auto-scaling does not work well in vertical scaling.

Demand for APIs will inevitably change over time. It will be necessary to scale API capacity up or down. Horizontal and vertical scaling are both available options for APIs. However, the stateless nature of APIs, coupled with the relative ease of horizontal auto-scaling, favors horizontal scaling as the right approach to scaling up APIs.

Horizontal vs. Vertical Scaling FAQs

How does horizontal scaling affect an API’s performance?

Horizontal scaling has a positive impact on an API’s performance. This approach involves adding more servers to your infrastructure and distributing the load among them. As a result, the system can handle more concurrent requests, leading to improved response times and enhanced overall performance.

In addition to performance benefits, horizontal scaling contributes to the redundancy and reliability of the system. If one server fails, the load balancer diverts traffic to remaining servers that can seamlessly take over, ensuring continuous operation. This aligns with API security best practices and enhances the system’s resilience against potential failures. Read the API security checklist to protect your API against potential threats.

How does vertical scaling affect an API’s performance?

Vertical scaling involves upgrading the resources of a single server to enhance its performance. This can improve the processing speed for API requests, as a more powerful server can handle a higher load. However, it’s important to note that vertical scaling may have diminishing returns. There are limits to how much you can upgrade a single machine. Beyond a certain point, the performance gains may not be proportional to the investment.

When considering horizontal vs. vertical scaling, weighing the potential benefits against the risks is crucial. Keep in mind things like REST API security implications and ensure that the system remains resilient to failures.

When should I use horizontal scaling vs. vertical scaling?

It’s important to understand the difference between horizontal and vertical scaling to determine when to use each one. Use vertical scaling when:

  • Your application is in its early stages or has a light load, which a single powerful server can effectively handle. This is especially true when the demand for API calls is low.
  • The application or API doesn’t support distributed computing well. In cases where the architecture or design doesn’t align with horizontal scaling principles, vertical scaling can be a suitable alternative.

Use horizontal scaling when:

  • Your application is experiencing growth, and demand is likely to spike. Horizontal scaling allows the infrastructure to adapt to changing loans by adding more servers as needed.
  • You need to ensure high availability and redundancy. Horizontal scaling provides redundancy, making the system more resilient to failures and ensuring continuous operation even if one or more servers go down.

Is horizontal scaling or vertical scaling more cost-effective?

The cost-effectiveness of horizontal scaling vs. vertical scaling depends on factors like the application’s specific requirements, deployment scale, and overall demand. Vertical scaling is typically more cost-effective because you only buy one or two new components when you scale. However, it becomes less cost-effective as you approach the limits of the server’s capacity.

Related Resources (Tab to skip section.)

Related Resources

WhitepaperAPI Security Disconnect 2023Discover how prepared your CIO, CISO, CTO, and AppSec peers are across financial services, retail, healthcare, government, manufacturing, and…Read
Ebook2023 OWASP API Security Top 10 Best PracticesAfter four long years since the original guidelines were created, the Open Web Application Security Project (OWASP) has now updated their Top 10…Read
Product BriefAPI Posture ManagementAssess your APIs and broader infrastructure for misconfigurations and vulnerabilities to identify potential risks.Read

Harold Bell

Horizontal vs. Vertical Scaling: Which Is Best for APIs? (4)

Horizontal vs. Vertical Scaling: Which Is Best for APIs? (5)

Harold Bell was the Director of Content Marketing at Noname Security. He has over a decade of experience in the IT industry with leading organizations such as Cisco, Nutanix, and Rubrik, and has been featured as an executive ghostwriter in Forbes Technology Council and Hacker News.

All Harold Bell postsAll of Harold Bell's posts
Horizontal vs. Vertical Scaling: Which Is Best for APIs? (2024)

FAQs

Horizontal vs. Vertical Scaling: Which Is Best for APIs? ›

Horizontal scaling, the right choice for APIs

When to choose horizontal scaling vs vertical scaling? ›

If you are working on a tight budget and need to add more resources to your infrastructure quickly and cheaply, then vertical scaling may be the best option for you. Future-proofing – Adding additional updated machines through horizontal scaling will increase the overall performance threshold of your organization.

What is horizontal scaling and its role in restful API architecture? ›

Horizontal scaling, also known as scaling out, refers to the process of increasing the capacity or performance of a system by adding more machines or servers to distribute the workload across a larger number of individual units.In this approach, there is no need to change the capacity of the server or replace the ...

What is horizontal and vertical scaling in microservices? ›

Vertical scaling means adding more resources to single server while horizontal scaling means adding more instances that's why vertical scaling is now as scale up and horizontal scaling is known as scale out.

Which type of scaling is better? ›

Automated horizontal scaling is the ideal scaling strategy because it enables efficient scaling, improves performance, lowers downtime, improves resiliency, and optimizes cost. However, it is not suitable for all workloads. The system must be architected in a distributed cluster to take advantage of horizontal scaling.

Which scaling is preferred? ›

The vertical scaling approach

One of the advantages of scaling vertically is that it is easier than the alternative horizontal scaling approach. Specifically, since hardware resources and/or computing resources are only being added to one machine, there is less complexity involved.

What is vertical scaling vs horizontal scaling in API? ›

Horizontal scaling adds more machines to a system, distributing the load. Vertical scaling upgrades a single machine's CPU, RAM, and storage. The choice depends on system architecture and application needs. Demand for an application programming interface (API) is usually not static.

How to increase scaling in rest APIs? ›

Practices to Enhance REST APIs Scalability
  1. Implement Caching: Implementing cache controls allows clients to store responses and reuse them, reducing the load on your server. ...
  2. Use a Load Balancer: As traffic grows, a single server may struggle to keep up.
Jul 16, 2023

What are the challenges of vertical scaling? ›

Single Point of Failure: Since vertical scaling focuses on a single server, it increases the risk of data loss in the event of a hardware or software failure. Hardware Limitations: There's a limit to how much you can scale up a single server. Every machine has a threshold for RAM, storage, and processing power.

What is the difference between horizontal and vertical scaling in Kubernetes? ›

Horizontal scaling means that the response to increased load is to deploy more Pods. This is different from vertical scaling, which for Kubernetes would mean assigning more resources (for example: memory or CPU) to the Pods that are already running for the workload.

How to make microservices more scalable? ›

There are two main ways to scale microservices: Horizontal scaling: This involves adding more microservice instances to handle the increased load. It's the most common type of scaling for microservices. You can add new containers or virtual machines to distribute the load across multiple instances.

What is the benefit of horizontal scaling? ›

Horizontal scaling has both advantages and disadvantages. Firstly, this approach simplifies scaling at hardware level. All that needs to be done is to add additional machines to the existing pool, and this eliminates the need to analyze the characteristics of the system to be upgraded. This model also reduces downtime.

Is vertical scaling better than horizontal scaling Facebook ads? ›

For instance, if you have a profitable campaign with a good Return on Ad Spend (ROAS), you might opt for vertical scaling to slowly increase the reach of your campaign. On the other hand, if you're looking to quickly expand your reach, horizontal scaling might be the better option.

Is vertical scaling cheaper than horizontal scaling? ›

Horizontal scaling is more expensive than vertical scaling because it involves higher upfront hardware costs and requires re-architecting a software system. Companies with limited budgets should go for vertical scaling because an increasing number of powerful multi-core machines are now packaged in a single box.

What is the difference between horizontal scaling and vertical scaling in performance testing? ›

Horizontal scaling distributes workload by adding instances, offering scalability and fault tolerance, while vertical scaling increases resources of existing machines, providing simplicity and high performance but limited scalability and potential single points of failure.

Top Articles
USPS Delivered at DDU: What You Need to Know | ShipScience Blog
Is Online Bill Pay Safe? - Experian
Kevin Cox Picks
Cooking Chutney | Ask Nigella.com
Is pickleball Betts' next conquest? 'That's my jam'
What to Serve with Lasagna (80+ side dishes and wine pairings)
Craigslist In South Carolina - Craigslist Near You
Craigslist Cars And Trucks Buffalo Ny
Ohiohealth Esource Employee Login
Infinite Campus Parent Portal Hall County
Oriellys St James Mn
Ap Chem Unit 8 Progress Check Mcq
Herbalism Guide Tbc
Shooting Games Multiplayer Unblocked
Theycallmemissblue
Washington Poe en Tilly Bradshaw 1 - Brandoffer, M.W. Craven | 9789024594917 | Boeken | bol
Classic Lotto Payout Calculator
Most McDonald's by Country 2024
Po Box 35691 Canton Oh
24 Hour Drive Thru Car Wash Near Me
Hocus Pocus Showtimes Near Amstar Cinema 16 - Macon
Amazing deals for DKoldies on Goodshop!
Petco Vet Clinic Appointment
Vigoro Mulch Safe For Dogs
Kayky Fifa 22 Potential
Breckie Hill Mega Link
R. Kelly Net Worth 2024: The King Of R&B's Rise And Fall
Project Reeducation Gamcore
Surplus property Definition: 397 Samples | Law Insider
Cars & Trucks - By Owner near Kissimmee, FL - craigslist
Tracking every 2024 Trade Deadline deal
Craftsman Yt3000 Oil Capacity
Greencastle Railcam
Lake Dunson Robertson Funeral Home Lagrange Georgia Obituary
Tenant Vs. Occupant: Is There Really A Difference Between Them?
Solemn Behavior Antonym
Tal 3L Zeus Replacement Lid
Imperialism Flocabulary Quiz Answers
Craigslist Mexicali Cars And Trucks - By Owner
Lovely Nails Prices (2024) – Salon Rates
Gfs Ordering Online
ESA Science & Technology - The remarkable Red Rectangle: A stairway to heaven? [heic0408]
Pain Out Maxx Kratom
Frontier Internet Outage Davenport Fl
Kjccc Sports
Sinai Sdn 2023
Bedbathandbeyond Flemington Nj
Rovert Wrestling
Solving Quadratics All Methods Worksheet Answers
O.c Craigslist
Jasgotgass2
Who We Are at Curt Landry Ministries
Latest Posts
Article information

Author: Duane Harber

Last Updated:

Views: 5781

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Duane Harber

Birthday: 1999-10-17

Address: Apt. 404 9899 Magnolia Roads, Port Royceville, ID 78186

Phone: +186911129794335

Job: Human Hospitality Planner

Hobby: Listening to music, Orienteering, Knapping, Dance, Mountain biking, Fishing, Pottery

Introduction: My name is Duane Harber, I am a modern, clever, handsome, fair, agreeable, inexpensive, beautiful person who loves writing and wants to share my knowledge and understanding with you.