Horizontal vs vertical scaling: when to add servers and when to make them bigger
When an application runs out of capacity there are two basic moves.
Vertical scaling (scale up): move to a bigger machine with more CPU, RAM or faster disks.
- Simple: no code changes, no distributed-system headaches
- Works especially well for databases, which are hard to split
- Has a ceiling, gets disproportionately expensive at the top end, and leaves a single point of failure
Horizontal scaling (scale out): add more machines and spread the load.
- Near-unlimited growth for stateless services like web servers and workers
- Better resilience, since losing one node is not fatal
- Requires a load balancer and an application designed for it: no local session state, shared storage, idempotent jobs
A common progression:
- Start on one modest server.
- Scale up until it gets expensive or risky.
- Make the app tier stateless and scale it out behind a load balancer.
- Keep the database vertical as long as possible, adding read replicas and caching.
- Only shard data when you truly must.
Modern hardware is powerful, and many workloads fit on a single large machine far longer than people assume. Distributed systems carry real operational cost.
Where did your own systems hit the limit of vertical scaling first? Has anyone gone the other way and consolidated many small servers into fewer big ones?
Comments · 4
Beginner version: scale up is a bigger computer, scale out is more computers. Scaling out needs your app to work across several.
Start vertical. It's cheaper in engineering time, and you rarely need horizontal until the product has real traffic.
Does the database scale the same way, or is it a different problem?
Different and harder. Reads scale out with replicas fairly easily, writes need sharding or a distributed database, which adds complexity.