Bookmarks

Horizontal and vertical scaling

Two ways to grow a system’s capacity: horizontal adds new machines, vertical increases the resources of the existing one.

Also: scaling, scale out, scale up, horizontal scaling, vertical scaling

checked 9 Nov

All terms

When demand for a service grows, a single server sooner or later runs out of capacity. Beyond that there are two paths: add more identical servers and spread requests between them (scale out), or replace the server with a more powerful one — one with more cores and memory (scale up). The choice shapes the application’s architecture.

Two approaches

CriterionHorizontal (scale out)Vertical (scale up)
What you doadd more nodes of the same typeupgrade a single node: CPU, memory, disk
Limitpractically unlimited, bounded by budget and networkthe limit of the largest machine
What it takesa load balancer, shared state storageusually nothing: the code stays unchanged
Node failurethe rest keep workingthe node is a single point of failure

Where the limit lies

The limit of vertical scaling is the most powerful server available: the number of processors, the amount of memory and disk cannot grow forever. Once that limit is reached, the horizontal path is all that remains.

Horizontal scaling runs into a different limit — application state. So that any node can serve any request, the service is made stateless: data is kept in external storage — a database, a cache or object storage — and sessions in shared storage or in tokens on the client. The more nodes, the higher the overhead of keeping them in sync.

Example

A web application on a single server with 64 GB of memory handles 2,000 requests per second. Growth to 8,000 requests can be met vertically — with a 256 GB server — or horizontally, with four servers behind a load balancer. The second path costs more to set up, but it does not run into the ceiling of a single machine and survives the failure of any node.

bashHorizontal scaling in Kubernetes: eight identical pods
kubectl scale deployment web --replicas=8

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • autoscaling

    Autoscaling adds and removes resources on its own, following metrics — and that process can run horizontally or vertically.

  • sharding

    Sharding divides data between nodes so that each holds its own share, rather than only spreading the load.

In depth in the references

where the topic is covered in detail