InfraSim system design guide

Horizontal vs vertical scaling

Six small instances or one large one: the same capacity, the same bill. The large one was faster, right up until its zone went dark.

Horizontal scaling means adding more machines and spreading requests across them. Vertical scaling means replacing a machine with a bigger one. Both add capacity. They differ in how fast each request is, what a failure takes with it, how far you can go, and how finely you can adjust.

The usual advice is "scale out, not up". The numbers below show why, and also where that advice is wrong.

The experiment

One load balancer in front of a compute pool, serving steady reads. We compared two pools with identical capacity and an identical simulated bill:

  • Horizontal: six Small instances.
  • Vertical: one Large instance, which in InfraSim has six times the capacity of a Small and costs six times as much.

Then we raised the load step by step and recorded the p95 latency. After that, we took one availability zone away.

Result 1: the big machine was faster

Pool busy6 × Small, p951 × Large, p95Errors (both)
33%41 ms28 ms0%
50%46 ms35 ms0%
67%65 ms49 ms0%
75%114 ms78 ms0.2%
83%232 ms141 ms1.4%
90%479 ms254 ms3.1%

At every load, the single Large instance had the lower p95, and at 90% busy it was about half. Errors were the same for both, because errors come from how full the pool is, and both pools were equally full.

Why: in InfraSim's model a bigger instance also finishes each request sooner (a Large's base latency is about 7 ms, a Small's 18 ms). Requests on one server do queue more than requests spread over six, but here the faster service more than pays for it. Queueing theory agrees: at the same total capacity, one fast server beats several slow ones on response time.

So if latency under steady load were the only question, you would scale up.

Result 2: the big machine was a single point of failure

Same traffic, a third of capacity in use. Twenty seconds in, Zone B goes dark.

LayoutAvailability while Zone B is downSimulated cost / month
6 × Small, 3 in each zone100%$278
1 × Large in Zone B0%$278
2 × Large, 1 in each zone100%$470

Six small instances can be split across two zones. When one zone went, the other three instances carried everything at 100% availability; the p95 rose from 45 ms to 85 ms because they were now twice as busy. One Large instance lives in exactly one place, and when that place went, so did every request.

You can make the vertical setup survive, by running a second Large in the other zone. That cost $470 a month instead of $278: you pay for a whole second copy of your biggest unit. With small instances, the redundancy came free with the shape.

The other differences

The ceiling. Vertical scaling stops at the biggest instance you can buy. In InfraSim that is X-Large, thirteen times a Small. A pool can run 64 instances by hand and 128 with autoscaling. Real providers have the same shape: the largest machine is a hard wall, the number of machines mostly is not.

The step size. An autoscaler adds whole instances. Going from six Smalls to seven adds 17% capacity. Going from one Large to two adds 100%, and doubles the bill for the time it runs.

The catch with going wide. Horizontal scaling assumes any instance can answer any request. If an instance keeps a user's session in its own memory, the load balancer can send that user somewhere that has never heard of them. Shared session storage, or stateless requests, is the price of admission.

So which one?

Scale out for anything that has to stay up: you get fault isolation and fine-grained steps, and you can keep growing. Scale up when a component is hard to split, like a primary database that takes every write, and accept that it is now the thing you have to protect. Plenty of real systems do both: a wide, stateless app tier in front of a tall database.

About these numbers

They describe InfraSim's simulation, not a benchmark of real hardware. The engine models aggregate traffic per tick, with a fixed seed so the runs repeat exactly, and its sizes cost the same per unit of capacity so the comparison is only about shape. Costs are the game's simulated monthly figures.

Break it yourself

Advent of Outages door 7, "Same Building" puts every server in Zone B and then turns Zone B off. It is free in your browser with no account; the door opens on 7 December and stays open after.

In the InfraSim app, One Server Isn't Enough (chapter 1, free) is where instance count and instance size first stop being the same lever.

New to InfraSim? The first five campaign levels play in your browser right now. No install, no account.

Get InfraSim: System Design Game

InfraSim is a system-design game: drag load balancers, caches, databases and queues onto a canvas, deploy, and watch simulated live traffic flow through what you built. Then survive traffic spikes, zone outages and bot swarms across a guided campaign, endless Survival runs and a Daily Challenge. Tutorial and 15 levels free, with optional InfraSim Pro.

More about InfraSim