Course outline · 0% complete

0/29 lessons0%

Course overview →

Vertical vs horizontal scaling

lesson 2-1 · ~9 min · 4/29

Quiz

Warm-up from lesson 1-2: your one-box app is slow under load. What should you do before changing anything?

Two ways to get more capacity

Vertical scaling (scaling up): replace the box with a bigger box. More CPU cores, more RAM, faster disks. Nothing about your code changes.

Horizontal scaling (scaling out): keep the box, add more boxes just like it, and split traffic between them.

Vertical scaling is the right first move. It is one config change at your cloud provider and zero changes to your architecture. But it has two hard limits:

  1. A ceiling. The biggest machine money can buy is still one machine
  2. A price curve. Big machines cost more per unit of power, and doubling the hardware rarely doubles real throughput

And one quiet flaw: one box is still a single point of failure, one part whose death takes the whole system down. When it reboots, your product is offline.

Code exercise · python

Run this pricing table (numbers are typical cloud prices). Watch the cost per vCPU climb as machines get bigger. That curve is why vertical scaling gets expensive.

Why horizontal wins at scale

Horizontal scaling has no ceiling: need 10x capacity, run 10x the servers. It also removes the single point of failure, because when one server dies the others keep serving.

The cost: your architecture must change. Two new problems appear the moment you have two servers:

  1. Who sends each request to which server? That is the load balancer, next lesson
  2. What happens to data a server was holding in memory? That is state, lesson 2-3

Every large system ends up horizontal. The skill is knowing that the simple vertical move buys you time, and taking it, before doing the harder thing.

Code exercise · python

Your turn. Compare buying one 16-vCPU machine at $780/mo against eight 2-vCPU machines at $70/mo each (same total vCPUs). Print the vertical price, the horizontal price, and the monthly savings, formatted exactly as shown in the expected output.

Quiz

Your startup's one server is at 90% CPU. You have paying customers and two weeks of runway for engineering work. What is the most sensible first move?