Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 80

Vertical vs. Horizontal Scaling: Limitations Explored

Recommended resources

Hello! Welcome to the first lesson of our new module: System Design and Scaling Patterns.

In the previous module, we focused on the internals of a single application, tracing a request and even offloading work to a reliable background task queue. We've built solid, resilient components. Now, it's time to zoom out. A modern backend isn't just one application on one server; it's an ecosystem of services working together. The fundamental question we'll start with is: what do you do when one server is no longer enough to handle the demand?

This lesson tackles that question head-on. We'll explore the two primary strategies for increasing a system's capacity to handle load: vertical scaling and horizontal scaling. You'll learn what each approach entails, their core trade-offs, and—most importantly—their fundamental limits.

By the end of this lesson, you will be able to compare vertical scaling (scaling up) and horizontal scaling (scaling out), explaining the limits of each, and start thinking about which strategy is appropriate for different parts of a backend system.

The Core Problem: A Single Server's Limits

Imagine your Django application, running on a single server, becomes incredibly popular. As more users connect, the server's CPU, memory, and network connections become overwhelmed. Response times climb, users experience errors, and the system grinds to a halt. You need to increase capacity. This need to handle more load by adding resources is the essence of scalability.

You have two fundamental choices:

  1. Make your current server bigger and more powerful.
  2. Add more servers and distribute the work.

These two choices represent the two philosophies of scaling.


Defining Vertical and Horizontal Scaling

Let's start with clear definitions and a visual aid.

  • Vertical Scaling (Scaling Up): This involves increasing the resources of a single machine. Think of it as upgrading your car's engine—you're making one unit more powerful. This means adding more CPU cores, more RAM, or faster storage to an existing server.

  • Horizontal Scaling (Scaling Out): This involves adding more machines to your pool of resources. Think of it as adding more cars to a delivery fleet. Instead of one powerful server, you have multiple servers working in parallel, with the load distributed among them.

Visual Comparison of Vertical vs. Horizontal Scaling
This diagram shows the basic idea. Vertical scaling (left) makes a single unit bigger. Horizontal scaling (right) adds more units.
Vertical vs. Horizontal Scaling
This visual clarifies the actions. Vertical scaling involves making a single machine's resources (CPU, RAM) larger or smaller. Horizontal scaling involves adding or removing machine instances from a pool, typically managed by a load balancer.

To get a quick, dynamic overview of these concepts, the following video provides an excellent introduction.

System Design BASICS: Horizontal vs. Vertical Scaling

Gaurav Sen provides a concise introduction to why we need to scale and the fundamental difference between the two approaches.

Watch the segment from 02:33 to 04:03. This will solidify the core definitions of vertical and horizontal scaling and the motivation behind them.

Now that we have the basic definitions, let's dive into the trade-offs and limits of each approach.


Vertical Scaling (Scaling Up): The Path of Power

Vertically scaling is often the simplest first step. Your application and database are already on one machine, so making that machine more powerful seems like a natural solution.

Strengths of Vertical Scaling

  • Simplicity: Managing one large server is operationally simpler than managing a fleet of smaller ones. There's less networking complexity, and deployments can be more straightforward.
  • Low Latency: Since all parts of your application (e.g., web server, database) can run on the same machine, communication between them is extremely fast (inter-process communication) instead of incurring network delays.
  • Data Consistency: For stateful services like a relational database, keeping all the data on one machine makes it much easier to guarantee strong consistency for transactions.

The Limits of Vertical Scaling

While simple at first, vertical scaling has hard limits that make it unsustainable for large-scale applications.

  1. Hardware Ceiling & Diminishing Returns: You can't add resources indefinitely. There's a physical limit to the number of CPU cores and amount of RAM a single motherboard can support. More importantly, the cost of high-end hardware grows exponentially. Doubling the power of a server often more than doubles its price. At some point, it becomes economically impractical to keep scaling up.

  2. Single Point of Failure (SPOF): This is a critical weakness. If your single, super-powerful server fails (due to a hardware issue, power outage, or software crash), your entire service goes offline. There is no backup to take over the load.

  3. Downtime for Upgrades: Scaling up often requires taking the server offline to install new hardware (e.g., more RAM, new CPU). This means scheduled downtime for your application, which may not be acceptable.

The following resource explains the financial and performance-related limits of vertical scaling very well.

Horizontal and Vertical Scaling (How to Scale Your Application) - System Design

Let's watch a section of a more detailed video by Caleb Curry that explores the concept of diminishing returns in hardware costs, which is a key limiter for vertical scaling.

Watch from 17:23 to 23:56. Pay close attention to the graph and the explanation of how the cost of hardware becomes exponential as you demand higher performance. This illustrates why, at a certain point, it becomes cheaper to scale horizontally.


Horizontal Scaling (Scaling Out): The Path of Distribution

Horizontal scaling is the foundation of most large, modern web services. It's designed to overcome the limits of vertical scaling by distributing the load across many (often cheaper, commodity) servers.

Strengths of Horizontal Scaling

  • High Availability and Fault Tolerance: By having multiple servers, the system can tolerate the failure of one or more machines. If a server goes down, a load balancer (a component we'll cover in the next lesson) simply stops sending traffic to it and directs it to the healthy servers. Your application stays online.
  • Elasticity and Cost-Effectiveness at Scale: You can add or remove servers in response to demand. This is the basis of "auto-scaling" in the cloud. During a traffic spike, you can automatically add more servers, and then remove them when traffic subsides, paying only for the capacity you use.
  • Theoretically "Infinite" Scale: Unlike the hard limits of a single machine, you can theoretically continue adding servers to handle ever-increasing loads.

The Limits of Horizontal Scaling

This power comes with its own set of challenges and complexities.

  1. Architectural Complexity: Managing a distributed system is significantly more complex than managing a single server. You need to consider:

    • Load Balancing: How do you distribute incoming requests evenly?
    • Service Discovery: How do services find and talk to each other?
    • Monitoring: How do you monitor the health of an entire fleet of machines?
    • Deployment: How do you deploy new code to dozens or hundreds of servers without downtime?
  2. Network Latency and Throughput: Communication between components now happens over the network, which is orders of magnitude slower than communication within a single machine. This can increase the overall response time for requests that require coordination between multiple services.

  3. Data Consistency: This is a major challenge for stateful applications. If you have multiple database servers, how do you ensure that data written to one server is visible to others? How do you handle transactions that span multiple machines? This trade-off between consistency, availability, and partition tolerance is so fundamental it has its own theorem (the CAP theorem), which we'll explore later in this module.

For a deeper dive into these trade-offs, particularly for stateless vs. stateful services, this video provides excellent context.

Horizontal and Vertical Scaling (How to Scale Your Application) - System Design

Let's return to Caleb Curry's video. This time, we'll focus on why horizontal scaling is straightforward for stateless APIs but complex for stateful databases.

First, watch from 14:34 to 17:00. This section explains the importance of scaling horizontally to at least two nodes for high availability and introduces the role of a load balancer. Then, watch from 26:27 to 32:00, which discusses the complexities of scaling databases and introduces patterns like read replicas.


Making the Decision: A Comparison Framework

So, which one do you choose? The answer is almost always: "It depends." The right strategy depends on the specific component you are scaling and your business requirements.

The following article provides a superb, developer-focused breakdown of these trade-offs.

Scaling Up vs Scaling Out: Why Your Infrastructure Strategy Could ...

The article 'Scaling Up vs Scaling Out' from Runpod offers a practical framework for making scaling decisions. We'll focus on its comparison table and decision matrix.

First, read the section 'Throughput vs Latency Trade-offs' to see a direct comparison table of performance metrics. Then, review the 'Decision Matrix Framework' and the summary table within it. This will help you synthesize the factors that guide the choice between scaling strategies.

Here is a summary of the key decision factors, inspired by the article:

Decision Factor Favors Vertical Scaling (Up) Favors Horizontal Scaling (Out)
Application Type Monolithic, stateful (e.g., traditional relational database) Microservices, stateless (e.g., API endpoints, web servers)
Growth Pattern Predictable, steady Rapid, unpredictable, spiky
Key Requirement Low latency, strong data consistency High availability, elasticity
Team Expertise Traditional system administration, hardware optimization Distributed systems, DevOps, container orchestration
Risk Tolerance Prefers lower operational complexity, can tolerate downtime Must have high availability, can manage system complexity
Cost Model High upfront investment (CapEx), lower operational complexity Lower upfront cost, pay-as-you-go (OpEx)

The Hybrid Approach: The Reality of Modern Systems

In practice, large-scale systems rarely use just one strategy. They use a hybrid approach, applying the right scaling strategy to the right part of the system.

A classic example is a typical web application like the ones you've built with Django:

  • Web/Application Tier: This tier is usually stateless (it doesn't store data between requests). This makes it a perfect candidate for horizontal scaling. You can run multiple instances of your Django application behind a load balancer to handle incoming web traffic.
  • Database Tier: This tier is stateful. It needs to maintain data integrity and consistency. It often benefits from the low latency and simplicity of vertical scaling. So, a common pattern is to start with one very powerful database server. As read load increases, you can add read replicas (a form of horizontal scaling for reads) while keeping a single, powerful primary server for writes.

This multi-tier strategy leverages the strengths of both approaches, creating a system that is both performant and resilient.


Conclusion

You now have a foundational understanding of the two primary ways to scale a backend system. This is a critical first step in thinking like a system architect.

Key Takeaways:

  • Vertical Scaling (Scaling Up) involves making a single server more powerful. It's simple and offers low latency but is limited by a hardware ceiling, high costs, and being a single point of failure.
  • Horizontal Scaling (Scaling Out) involves adding more servers to a pool. It offers high availability and elastic scale but introduces significant architectural complexity and network latency.
  • The choice between them is a trade-off. It depends on the specific requirements of the application component, including its need for state, consistency, availability, and your budget.
  • Most modern systems use a hybrid approach, scaling stateless components horizontally and stateful components vertically (at least initially).

Preview of the Next Lesson

We've established that for high availability and handling large traffic volumes, horizontal scaling is essential. But if you have multiple servers, how do you decide which one should handle an incoming request? That's the job of a load balancer. In our next lesson, we will dive deep into how load balancers work, exploring common algorithms they use to distribute traffic and their critical role in a scalable architecture.