System Design · Concept Library · Free article
Horizontal Scaling — Add Boxes, and What Won’t
Why the answer to “we’re out of capacity” is usually more machines, not a bigger one — and the harder truth of where adding machines stops helping. Scale-up vs scale-out, the limits (2× boxes ≠ 2× throughput), autoscaling, and the one tier that refuses to scale out. For interns through principal engineers.
Horizontal scaling means handling more load by adding more machines (scale out), instead of making one machine bigger (scale up). Scaling up is simpler but hits a hard ceiling — there’s a biggest box, it costs superlinearly, and it’s still one box to lose. Scaling out has no ceiling and survives a machine dying, which is why it’s how everything large is built — but it isn’t free: 2× the servers rarely means 2× the throughput (coordination and a shared bottleneck eat the gains), and it only works if your servers are stateless so any of them can handle any request. The real frontier is what can’t be cloned: your stateless app tier scales out trivially, but the stateful data tier — one database owning the writes — is the hard part, and tackling it (replication, then sharding) is the next chapter of the journey.
You bought the biggest box — and it’s still maxing out
Picture the moment most systems hit. Traffic’s been climbing for months, so each time the server got busy you did the obvious thing: moved it to a bigger machine. More cores, more memory, a faster disk. It worked every time — until the day you go to upgrade again and there is no bigger machine to buy. You’ve hit the top of the menu. The box is pegged, users are waiting, and the lever you’ve always pulled is out of travel.
That wall has a name, and so does the way around it. Making one machine bigger is vertical scaling (scaling up); the way around the wall is to stop relying on one machine at all and spread the work across many — horizontal scaling (scaling out). This page is about that choice, the limits hiding inside it, and the one part of your system that stubbornly refuses to scale out no matter how many machines you throw at it.
Scale up vs scale out
The two directions sound symmetrical but behave nothing alike. Scaling up keeps your architecture exactly as it is and just rents a stronger machine — one box, but a beast. It’s wonderfully simple: no new moving parts, no coordination, your code doesn’t change. That simplicity is real and worth respecting; for a long time it’s the right answer. But it carries three quiet liabilities. There’s a hard ceiling — the largest instance you can buy is a fixed thing, and once you’re on it you’re done. The price curve bends the wrong way — doubling a single machine’s power costs more than double, because the top end of hardware is a premium. And it’s still one box to lose — all your eggs, one basket; that machine’s failure is your whole outage.
Scaling out trades that simplicity for headroom. Instead of one beast you run many ordinary machines and share the load across them. Now there’s no ceiling — need more, add more — and the cost grows roughly linearly (ten cheap boxes cost about ten times one, not forty times). And losing a machine is survivable: the others carry on. Slide the target load below and watch the difference — the single big box slams into its ceiling and its cost soars, while the pool just grows another machine:
The interactive version of this example is available when JavaScript loads.
There’s a second, sharper difference that the cost curve hides: what happens when a machine dies. Scaling up concentrates everything on one node, so its failure is total. Scaling out spreads the work, so any single machine failing just trims a slice of capacity — the system stays up, a little smaller, while the box is replaced. Watch a load spike hit both, then kill a machine in each:
The interactive version of this example is available when JavaScript loads.
Two servers don’t give you twice the throughput
Here’s the assumption that quietly breaks: “just add more machines and capacity grows to match.” If only. Adding a second server rarely doubles your throughput, and by the tenth the returns are visibly shrinking. Two forces eat the gains, and a senior engineer can name both.
The first is the part of the work that can’t be parallelised. Almost every request has some serial slice — a lock, a single coordinator, one shared counter — that only one machine can do at a time. No matter how many servers you add, that slice doesn’t get faster, so it caps your total speedup. (This is Amdahl’s law: if even 5% of the work is serial, you can never go more than 20× faster however many machines you add.) The second is coordination overhead — more machines means more chatter to stay in sync, more connections, more cache coherence, more things that can disagree. Past a point, each new machine adds more overhead than capacity.
Drag the serial fraction below and watch the speedup curve flatten — notice how a tiny bit of un-parallelisable work puts a hard ceiling on what any number of machines can buy you:
The interactive version of this example is available when JavaScript loads.
Scaling out only works if any machine can do any job
There’s a precondition that makes the whole thing possible, and it’s easy to miss until it bites. For a pool to share work freely, any server has to be able to handle any request — which means a server can’t hold anything important in its own memory or on its own disk. The moment a request depends on landing on the specific machine that handled the last one (because that machine remembers who you are, or holds your half-finished upload), you can’t freely spread the load, and a machine dying takes real data with it. A server that keeps no such local memory is stateless; one that does is stateful.
The fix isn’t to remember better — it’s to keep the state somewhere every server can see, so no single machine is special. Push it out: sessions into a shared store (Redis) or a signed token the client carries; uploaded files into object storage; the source of truth into the database. Now every app server is interchangeable, the load balancer can route however it likes, and a dead box takes nothing down with it. Decide which of these can scale out, and why:
The interactive version of this example is available when JavaScript loads.
Autoscaling: grow and shrink with the load
Once your servers are cattle, you don’t have to guess your capacity in advance — you can let the system add and remove machines itself as load moves. That’s autoscaling, and it’s the real prize of scaling out: you pay for roughly what you’re using, ride out spikes without a pager, and shrink back down when the rush passes. Watch an autoscaler track a traffic wave — adding instances as it climbs, releasing them as it falls:
The interactive version of this example is available when JavaScript loads.
The three ways to decide when to scale
- Reactive (metric-driven) — watch a signal (CPU, request rate, queue depth) and add machines when it crosses a threshold, remove them when it drops. The default. Simple, but it only reacts after load arrives, so there’s a lag.
- Scheduled — scale on a calendar you already know (up before the 9am rush, down overnight). Great for predictable patterns; blind to surprises.
- Predictive — forecast load from history and scale ahead of it, so capacity is ready before the spike lands. Most sophisticated; needs good data and trust in the model.
The part that won’t scale out: your data
Everything so far has a happy ending because the app tier is stateless — clone it as wide as you like. But hold the whole picture in your head and the hard truth appears: those fifty interchangeable app servers are all talking to one database, and that database is stateful by definition — it’s the source of truth, the one place the real data lives. You can’t just run fifty copies of it the way you run fifty app servers, because then which copy is right? The instant two of them accept different writes, your truth has forked.
So the stateless tier scales out almost for free, and the stateful data tier is where scaling gets genuinely hard. That’s not a footnote — it’s the whole next stretch of the journey. The moves are real and they have names: keep extra read-only copies of the data in sync to spread the reads (replication), and split the data into independent pieces that each live on their own machine to spread the writes (sharding). Each buys scale at the price of new, subtle problems — staleness, consistency, rebalancing — which is exactly why they get their own chapters later in the journey.
When *not* to scale out
Scaling out is powerful, which is exactly why it’s over-reached for. Every machine you add is real complexity — a fleet to deploy, monitor, secure, and keep in sync — and that complexity is a cost you pay forever, not just once. The honest default for a young or modest system is the opposite of impressive: run one well-sized box (with backups and a plan to restore), and scale up while that’s cheaper and simpler than a fleet. You add machines when you’ve measured a reason to.
Signs you’re scaling out too early
- One box still has headroom. If your single server runs at 30% on a busy day, a fleet is just complexity with no payoff — scale up later if you must.
- The bottleneck is the database, not compute. Adding stateless app servers in front of a saturated database does nothing. Fix the real wall (cache, replicas, sharding) first.
- The work isn’t parallelisable. If a job is mostly one serial chain, more machines can’t speed it up (Amdahl) — you need a better algorithm, not a bigger fleet.
- You’d be trading a simple problem for a distributed one. Distributed systems bring partial failure, consistency, and coordination bugs. Don’t take them on for traffic a single box handles comfortably.
How it’s actually run
You rarely manage a fleet by hand. An orchestrator does it — you declare “I want N copies of this stateless service, scaled on CPU,” and it places them on machines, restarts the ones that die, and adds or removes copies as load moves. Kubernetes is the common one (a Deployment with a HorizontalPodAutoscaler); cloud platforms offer the same shape as auto-scaling groups behind a managed load balancer. The pieces map straight onto this page: identical stateless replicas (cattle), a balancer in front, a health check deciding who’s in rotation, and an autoscaler watching a metric. You don’t need to know one product deeply — you need to recognise the shape, because every platform implements the same idea.
Pitfalls
- Scaling out a stateful server. If a machine holds local session/state, a pool can’t share its load and a death loses data. Externalise the state first, then scale out.
- Adding app servers in front of a saturated database. The bottleneck moved to the data tier — more stateless boxes do nothing. Find the current bottleneck before scaling it.
- Expecting linear speedup. A serial slice (a lock, a coordinator) caps total throughput no matter how many machines you add (Amdahl). Measure the real curve.
- Scaling in too aggressively. A twitchy scale-in thrashes the fleet and re-pays cold-start costs. Scale out fast, scale in slow, with a cooldown.
- Reaching for a fleet too early. A single well-sized box plus backups is simpler and cheaper for modest load. Scale out on a measured reason, not by reflex.
- Forgetting the data tier. “We’ll just scale out” quietly assumes the database keeps up. It won’t — plan for replication/sharding as the real frontier.
Best practices
- Scale up first, out when you must — buy simplicity while it’s cheaper than a fleet; scale out at the ceiling, the cost bend, or the single-point-of-failure line.
- Make servers stateless before you scale out — push session/state to a shared store or token so any machine serves any request (cattle, not pets).
- Find the real bottleneck before adding machines — relieve the resource that’s actually capping you; don’t scale the app tier when the database is the wall.
- Autoscale on a leading signal; out fast, in slow — beat cold starts by scaling early, and add a cooldown so the fleet doesn’t flap.
- Plan the data tier separately — assume the stateless part scales out; design replication/sharding for the stateful part deliberately.
- Let an orchestrator run the fleet — declare desired replicas + a scaling policy rather than nursing individual machines.
Rapid-fire cheat-sheet (intern → principal)
- "Vertical vs horizontal scaling?"
- Vertical = a bigger machine (simple, but a hard ceiling, superlinear cost, and one box to lose). Horizontal = more machines sharing the load (no ceiling, ~linear cost, survives a failure — at the price of coordination and needing stateless servers). Scale up first; out when you must.
- "Why doesn’t adding servers double the throughput?"
- Amdahl’s law — the un-parallelisable slice (a lock, a coordinator) caps total speedup no matter how many machines you add — plus coordination overhead (sync, connections, cache coherence) that grows with the fleet. And the bottleneck often just moves to the database.
- "What does a server need to be to scale out?"
- Stateless — it keeps nothing important in local memory or disk, so any machine can serve any request and a death loses nothing. Push session/state to a shared store or a signed token; files to object storage. "Cattle, not pets."
- "How does autoscaling decide when to add machines?"
- Reactive (a metric like CPU/queue depth crosses a threshold), scheduled (known calendar patterns), or predictive (forecast ahead of the load). Scale out fast on a leading signal to beat cold starts; scale in slowly with a cooldown to avoid flapping.
- "What doesn’t scale out, and what do you do about it?"
- The stateful data tier — one database owns the writes, so you can’t just clone it. Spread reads with caching and read replicas; spread writes by sharding the data across machines. Each adds consistency/staleness/rebalancing problems, which is why it’s the hard part.
- "How would you scale this system?" (the meta-question)
- Split it in two. The stateless app tier scales out behind a load balancer — easy: make it stateless, put it in a pool, autoscale it. The stateful data tier is the real work — measure the bottleneck, then cache + read replicas for read load, sharding for write load. Knowing which half is which is the answer.
The takeaway
By GOAT Engineer. Back to Concept Library. Privacy Policy · Contact.