Skip to content
Veltoryx Technologies
FreeLesson 1.4Beginner8 min readUpdated 31 October 2026

Vertical vs Horizontal Scaling and Stateless Architecture

Scaling up vs scaling out, hardware cost curves, stateless web tiers, externalizing user state, and designing systems that scale horizontally without limits.

When an application experiences traffic growth that outstrips its server capacity, an engineering team has only two fundamental ways to expand: they can make the existing machine bigger, or they can add more machines.

Making a single machine bigger is Vertical Scaling (scaling up). Adding more machines in parallel is Horizontal Scaling (scaling out). While vertical scaling is the easiest short-term fix, building systems that scale horizontally without friction requires an architectural discipline called statelessness.

Vertical vs Horizontal Scaling and Stateless Architecture
Fig. 1 · Vertical vs Horizontal Scaling and Stateless Architecture

01Comparing Vertical and Horizontal Scaling

To choose between scaling up and scaling out, you must understand the mechanical trade-offs of both approaches:

DimensionVertical Scaling (Scale Up)Horizontal Scaling (Scale Out)
MethodAdding more CPU, RAM, or faster NVMe disks to a single machineAdding more independent commodity servers behind a load balancer
ComplexityZero architectural changes; run the same code on a larger VMRequires load balancing, service discovery, and external state stores
Hardware LimitHard physical ceiling (e.g. max 128 cores, 2TB RAM on a single board)Virtually infinite capacity (add 10, 100, or 1,000 servers on demand)
Cost CurveExponential (high-end enterprise hardware has steep pricing curves)Linear (composed of cheap, cost-effective commodity cloud instances)
DowntimeUpgrades usually require rebooting or stopping the serverZero downtime (new nodes join the pool dynamically while live)
Fault ToleranceZero redundancy; the single machine remains a single point of failureHigh resilience; individual node crashes have zero impact on the pool

The Non-Linear Cost Curve of Scaling Up

A common misconception is that doubling the hardware of a server doubles the cost. In reality, server hardware pricing is non-linear:

  • An entry-level cloud virtual machine with 4 CPU cores and 16GB RAM might cost approximately $50 per month.
  • A mid-tier machine with 16 CPU cores and 64GB RAM costs around $200 per month (4x the resources for 4x the price).
  • An extreme-tier machine with 128 CPU cores and 1TB RAM can cost $4,000 to $8,000 per month. You are paying 20x to 40x the price for only 8x the computing power because top-tier silicon and specialized multi-socket motherboards carry huge manufacturing premiums.

Horizontal scaling lets you run thirty $50 nodes instead of a single $4,000 monster machine, slashing infrastructure spend while gaining high availability across multiple datacenters.

02The Secret to Horizontal Scale: The Stateless Tier

If horizontal scaling is cheaper, more resilient, and virtually unlimited, why doesn't every team scale horizontally from Day 1?

The answer is state.

The Stateful Trap (Sticky Sessions)

In early web development, application servers maintained user state in local server memory (RAM):

text
Stateful Architecture (Fragile):
User Alice -> logs in -> Server 1 saves session {userId: 101, cart: ['Laptop']} in RAM.
User Bob   -> logs in -> Server 2 saves session {userId: 102, cart: ['Phone']} in RAM.

If Alice makes a second request to view her cart, her request must be routed to Server 1. If the load balancer routes her to Server 2, Server 2 has no record of her session in its RAM, and Alice is suddenly forced to log in again or sees an empty shopping cart.

To make stateful servers work behind a load balancer, teams resorted to Sticky Sessions (Session Affinity):

  • The load balancer inspects a cookie or the user's IP address and forces all subsequent requests from that user to go to the exact same physical server.

Why Sticky Sessions Break Horizontal Scaling:

  1. Uneven Load Distribution: If 1,000 high-frequency users get assigned to Server 1, Server 1 runs hot at 95 percent CPU while Server 2 and Server 3 sit idle at 10 percent CPU. The load balancer cannot rebalance traffic dynamically.
  2. Loss of High Availability: If Server 1 experiences a hardware crash or is terminated by auto-scaling, every single user session stored in Server 1's RAM is lost permanently. Active shopping carts vanish.
  3. Deployment Friction: You cannot easily perform a rolling deployment or scale down at night without abruptly kicking users off the platform.

The Stateless Architecture Solution

To make an application tier truly horizontally scalable, you must externalize all state:

text
Stateless Architecture (Resilient):
User Alice -> Request -> Load Balancer -> Server 1 -> Checks Redis Cache for session
User Alice -> Request -> Load Balancer -> Server 3 -> Checks Redis Cache for session

In a stateless architecture:

  1. Application servers contain only business logic and code. They hold zero persistent user data, zero session objects, and zero uploaded files on their local disks.
  2. When a user logs in, the session token, user permissions, and cart contents are stored in a centralized, high-speed in-memory store like a Redis cluster or a distributed cache.
  3. Every incoming request carries an authentication token (such as a signed JWT or session ID header).
  4. Any server can answer any request from any user at any moment.

When your application tier is completely stateless, scaling out is effortless. If your monitoring detects CPU utilization crossing 70 percent on Black Friday, your auto-scaling group spins up 20 new application servers. The load balancer starts sending them traffic within seconds. When the traffic surge passes, 20 servers are safely terminated with zero data loss.

03What About Stateful Systems?

While making your application tier stateless is straightforward, data must ultimately be stored durably somewhere. The database tier (PostgreSQL, MySQL, Cassandra) is inherently stateful.

Scaling the stateful data tier horizontally requires specialized distributed patterns that we will explore throughout this track:

  • Read/Write Splitting: Separating write traffic to a Primary database and routing read queries across multiple read replicas.
  • Database Sharding: Partitioning data across multiple database instances using a hash key (e.g. Users 1 to 1,000,000 on DB 1, Users 1,000,001 to 2,000,000 on DB 2).
  • Distributed Caching: Placing an in-memory cache layer in front of the database to absorb 85 percent of all reads.

04In the interview

When an interviewer asks you to scale an architecture from 10,000 users to 10 million users:

  1. State the Decoupling Principle: "First, we will decouple the application logic from persistent state. We will extract all session state and user context from local server memory into an external distributed Redis cluster."
  2. Introduce the Load Balancer: "With the application servers rendered completely stateless, we can place them behind a Layer-7 load balancer. Any server can now serve any user request, allowing us to auto-scale our compute nodes linearly based on CPU and request latency metrics."
  3. Address the Database Bottleneck: "Because the compute tier can now scale horizontally without limits, the database will become the next bottleneck. We will address this by adding a caching layer and implementing read/write splitting before considering horizontal sharding."

05Check your understanding