Problem
A system outgrows its current capacity and the team must decide how to add more. Scaling up is simple but capped and risky, while scaling out demands that the application and data tier tolerate distribution.
Also known as: scale-out-vs-scale-up
Choose between adding bigger machines or more machines to meet growing load.
A system outgrows its current capacity and the team must decide how to add more. Scaling up is simple but capped and risky, while scaling out demands that the application and data tier tolerate distribution.
Vertical scaling (scale up) gives one machine more CPU, memory or disk. Horizontal scaling (scale out) adds machines and spreads work among them. Most architectures use both, at different tiers.
Vertical: [ 4 vCPU ] -> [ 32 vCPU ] one bigger node
Horizontal: [ node ] -> [ node ][ node ][ node ] behind a load balancer
Horizontal scaling works when requests are independent. Any instance can serve any request if state lives elsewhere: sessions in Redis, files in object storage, data in a database. The load balancer then distributes by round robin or least connections.
Data is the hard part. Reads scale out through replicas, writes through partitioning, and both need a strategy for routing and rebalancing. Until that is necessary, a single large database with good indexes is often the cheapest and most reliable choice. Modern instances offer hundreds of cores and terabytes of RAM, which postpones distribution for many products.
Amdahl's law applies: if 10 percent of work is serial, no number of nodes gives more than a 10x speedup. Find the serial parts first, such as locks, a single queue or one database primary.
Vertical: premium per unit; horizontal: more nodes and balancers
Medium: horizontal needs fleet management
Medium: distributed state concerns
Vertical resize requires restart and causes an outage
Horizontal scaling shifts the bottleneck to the shared database
Session affinity or local state breaks when instances are added