Vertical scaling (scale up) means using a bigger machine. Horizontal scaling (scale out) means adding more machines.
Vertical scaling gives one machine more CPU, more RAM or faster disks.
- Pros: it needs no code changes and keeps everything simple.
- Cons: it has a hard ceiling, because machines only get so big. It gets expensive at the top end. The machine is still a single point of failure: if it dies, everything stops.
Horizontal scaling puts more machines behind a load balancer. The load balancer spreads requests across them.
- Pros: it has no practical ceiling. It also gives redundancy, because other machines keep working if one fails.
- Cons: the application must be stateless, or keep shared state outside the machines. You also take on distributed problems, such as data partitioning and consistency.
When to choose each:
- Scale up first when it is cheap, especially for databases.
- Design the application tiers to be stateless, so they can scale out.
Stateless services scale horizontally easily. Stateful stores, such as databases, are where horizontal scaling gets hard.
- Vertical scaling means a bigger machine. It is simple, but it has a ceiling and is a single point of failure.
- Horizontal scaling means more machines. It gives redundancy, but the services must be stateless.
- Application tiers scale out easily. Databases are the hard part.
- Teams often scale up first, then scale out.
Read more