SDE Path

Vertical vs Horizontal Scaling (and when each wins)

11 min read

When your application reaches capacity, you have two levers: make a single machine stronger (vertical), or add more machines (horizontal). The choice drives every architectural decision that follows.

Vertical Scaling: Bigger Machine

What it is: Add more CPU, RAM, and disk to a single server. A 32-core box replaces an 8-core box.

Pros:

  • Simple: no distribution logic needed. Your code runs unchanged.
  • Lower latency: single machine, no network hops between components.
  • Consistency: one database, one source of truth, ACID transactions work naturally.
  • Cheaper per unit (initially): a 16-core machine costs less per core than two 8-core machines.

Cons:

  • Hard limit: largest available hardware. AWS has r6i.32xlarge (1 TB RAM, 128 vCPU), but that's it.
  • Expensive marginal cost: going from 64 GB to 128 GB often costs more than adding a new machine.
  • Single point of failure: one machine dies, system down. No redundancy.
  • Maintenance window: upgrading or patching means taking the whole system offline.

When it wins:

  • Startup phase: one fat server beats three small ones (simpler, cheaper upfront).
  • Stateful systems: a single cache or session store is easier to manage than distributed state.
  • Consistency-heavy workloads: financial transactions, strongly consistent data.

Horizontal Scaling: More Machines

What it is: Add multiple smaller instances and distribute load across them. A 100-node cluster replaces a 10-node cluster.

Pros:

  • Unlimited scale: add machines linearly (mostly). Netflix has millions of requests/sec via 10,000+ instances.
  • Redundancy: one node fails, traffic diverts. System stays up.
  • No maintenance window: add/remove nodes without stopping the world.
  • Cost flexibility: scale down during low traffic, scale up during peak.

Cons:

  • Complexity: distribution is hard. You need load balancers, coordination, failure detection.
  • Network latency: requests bounce between machines. Adds milliseconds.
  • Eventual consistency: strong consistency across machines is expensive. You likely trade it for eventual consistency.
  • Operational burden: more nodes = more to monitor, patch, debug.

When it wins:

  • Scale-out workloads: stateless services (APIs, workers) that can easily parallelize.
  • High availability: SLA demands 99.99% uptime (financial, healthcare).
  • Variable load: traffic spikes. Horizontal scales in minutes (auto-scaling); vertical requires a hardware upgrade.

Real-World Trade-Offs

Databases

Vertical: A single PostgreSQL on r6i.32xlarge can handle 50k-100k QPS on modern hardware. If your dataset fits in RAM and you don't have massive write volume, one fat machine with daily backups works great.

Horizontal: Once you exceed single-machine limits, split data via sharding (users split by user_id % 16 across 16 databases). Now you can scale to petabytes, but lose single-database transactions.

Hybrid: Many teams run a leader database (vertical, for writes + strong consistency) and replica followers (horizontal, for read scale).

Caches

Vertical: Redis on one machine: 100 GB RAM, millions of ops/sec. Fine for caches under 100 GB.

Horizontal: Redis cluster (horizontal sharding) or Memcached (already distributed). Needed when your cache size exceeds one machine's RAM or when a cache failure would hurt.

Application Servers

Vertical: A single Node.js process pins one CPU core. Adding cores within one machine means process pools or clustering (complexity).

Horizontal: Run 100 stateless Node instances behind a load balancer. Add/remove instances in seconds. Natural fit for cloud.


The Transition: From Vertical to Horizontal

Most systems follow this path:

  1. Phase 1 (Startup, < 1 million users): One server. App, database, cache on the same machine or adjacent. Vertical scaling every 6-12 months.

  2. Phase 2 (Growth, 1-10 million users): Separate database from app. App scales horizontally behind a load balancer. Cache layer added (Memcached/Redis).

  3. Phase 3 (Scale, > 10 million users): Database sharding. Read replicas in multiple regions. CDN for static content. Microservices (horizontal split by domain).


Mixing the Two

Vertical + Horizontal is common:

  • Run 10 machines with 16 cores and 64 GB RAM each (vertical, per machine) behind a load balancer (horizontal, across machines).
  • One database with 2-4 TB RAM (vertical) with 5 read replicas (horizontal for reads).

The right balance: Minimize operational complexity while meeting SLA. If your cluster is 5 machines and you can afford 15, scale horizontally (easier ops). If you have 100 machines because each is small, maybe consolidate to 20 bigger ones (fewer things to manage).


In the interview

  1. Understand the limits. Vertical scales until the largest AWS instance is full. Horizontal scales to infinity (cost is the limit).

  2. Mention tradeoffs early. "Vertical is simpler but hits a wall. Horizontal is unlimited but adds complexity—load balancing, consistency, failure handling."

  3. Ground in concrete numbers. "A single PostgreSQL on high-end hardware can do 50k-100k QPS. If you need 500k QPS, you shard horizontally." Numbers show you're grounded.

  4. Discuss hybrid approaches. "I'd start with one fat database, then add read replicas for horizontal read scale. Writes stay on the leader for consistency."

Check yourself

5 questions — graded when you submit.

Question 1

You're building a startup with an initial load of 500 requests/sec. A single server can handle 5,000 QPS. Why might vertical scaling alone be the right choice initially?

Question 2

A single PostgreSQL hits 50,000 QPS and is at 80% CPU. You need to support 200,000 QPS. Why can't you just buy a bigger machine?

Question 3

Why does horizontal scaling require a load balancer, but vertical scaling doesn't?

Question 4

A system has strong consistency requirements (financial transactions). Should you scale horizontally first?

Question 5

You have 100 stateless API servers behind a load balancer (horizontal), and one database. What's the bottleneck?

Finished reading?

Sign in to save your progress across lessons.