Horizontal Scaling
- In Turkish
- Yatay Ölçekleme
- Pronunciation
- hor-ih-ZON-tul SKAY-ling
In short
Horizontal scaling (scaling out) increases a system's capacity by adding machines and spreading the work across them, rather than making one machine bigger.
What is horizontal scaling?
When a web application gets more traffic than one server can handle, you can run it on two servers, then ten, with a load balancer sharing requests between them. Each server does the same job on a different part of the load. Cloud platforms make this easy: autoscaling groups and Kubernetes add and remove instances automatically as traffic rises and falls.
Scaling out has big advantages. Capacity can grow almost without limit, a single machine failing doesn't take the service down, upgrades can roll through instances one at a time without downtime, and many small machines can be cheaper than one giant one. Large internet services run on thousands of commodity servers for exactly these reasons.
It does require the right design. Application servers should be stateless, keeping sessions, uploads and caches in shared services such as Redis or object storage, so any instance can handle any request. Databases are harder to scale out: read replicas spread reads, but spreading writes means sharding the data, which complicates queries, transactions and operations.
A common misconception is that adding servers always adds speed. Shared bottlenecks, such as a single database, a lock or a slow external API, cap throughput no matter how many app servers you add, and coordination between nodes adds its own overhead. Measure where the bottleneck is before scaling out.
Key takeaways
- Horizontal scaling adds more machines and spreads the load.
- A load balancer and autoscaling distribute traffic across instances.
- It brings near-unlimited growth, fault tolerance and rolling upgrades.
- Servers must be stateless; databases need replicas or sharding.
- Shared bottlenecks limit gains, so measure before scaling out.
Readers ask
What is the difference between horizontal and vertical scaling?
Horizontal scaling adds more machines; vertical scaling makes one machine more powerful with more CPU, memory or faster storage. Horizontal scaling grows further and tolerates failures, while vertical scaling is simpler but hits hardware limits.
Why must servers be stateless to scale horizontally?
If a server keeps a user's session in its own memory, the next request must reach the same server. Moving state to a shared store lets the load balancer send any request to any instance and lets instances be added or removed freely.
Can databases scale horizontally?
Yes, with more effort. Read replicas handle more reads, and sharding splits data across servers to handle more writes. Some distributed databases, such as Cassandra or CockroachDB, are designed to scale out from the start.
Often compared
See also
- Vertical ScalingSoftware Architecture, p. 47Vertical scaling (scaling up) increases a system's capacity by giving a single machine more CPU, memory or faster storage, instead of adding more machines.
- ScalabilitySoftware Architecture, p. 36Scalability is a system's ability to handle growing amounts of work, such as more users or data, by adding resources without a drop in performance.
- Load BalancerDevOps & Cloud, p. 34A load balancer is a server or service that spreads incoming traffic across several backend servers so no single one is overloaded and the app stays available.
- AutoscalingDevOps & Cloud, p. 2Autoscaling is the automatic adding or removing of computing resources, such as servers or containers, based on demand to keep performance steady and costs low.
- ShardingDatabases, p. 39Sharding is a way of scaling a database by splitting its data across several servers, called shards, so each one stores and handles only part of the total.
- MicroservicesSoftware Architecture, p. 27Microservices are an architectural style where an application is split into small, independently deployable services that communicate over a network.
Spotted a mistake or something missing on this page?Suggest an edit