Notesfoundations🌱 seedling
Horizontal Scaling
Also: Scaling Out · Scale Out · Shared-Nothing Architecture
Horizontal scaling adds capacity by spreading load across more machines, each with its own CPU, memory and disk, coordinating over the network (shared-nothing). It has no hard ceiling, but for stateful systems it requires splitting the data.
Why it exists
One machine has a ceiling and is a single failure domain. Many commodity machines can grow almost without limit, survive individual failures and spread across regions.
How it works
- Stateless tiers scale trivially: a Load Balancer in front, add copies, any node serves any request.
- Stateful data must be split into shards (Partitioning) and usually copied (Replication). Then you own routing, rebalancing, hot keys and cross-shard queries.
- Elastic systems add and remove nodes automatically as load changes; others are scaled by hand.
Trade-offs
| Gains | Costs |
|---|---|
| practically no ceiling; commodity hardware | partial failures, network delays, coordination |
| survives node loss; can span regions | sharding is hard to retrofit (months of work) |
| fine-grained capacity steps | operational complexity: more machines to run and observe |
In practice
- Figma (2023): after vertical partitioning ran out, horizontally sharded Postgres behind a query router (DBProxy); the first table took about nine months.
- ChatGPT (2026): kept Postgres on one primary but is moving shardable, write-heavy workloads to sharded stores such as Cosmos DB.
Pitfalls
- Scaling out a database before you need to: you pay the distributed-systems tax every day.
- Assuming more nodes means more throughput when a shared dependency (one database, one hot key) is the real bottleneck.
Connections
- Part of
- Scalability
- Builds on this
- Hash PartitioningRange Partitioning
- Contrasts with
- Vertical Scaling
Recall
These cards are also in your review deck, scheduled with spaced repetition.