Why you need it
When one server cannot answer everyone, there are only two ways to get more power: make the server bigger, or add more servers. Each has a limit and a cost, and most of system design is about the second one.
Think of it like this
A restaurant with too many customers. You can hire one faster chef (scaling up) or open more kitchens next to each other (scaling out). One chef can only get so fast. More kitchens need someone at the door sending customers to each one.
Where you’ll find it
- Stack Overflow: Served one of the busiest sites in the world from a handful of big servers: scaling up, done well.
- Let's Encrypt: Kept its main database on one machine and upgraded to a bigger one when it got slow.
- AWS: Rents machines with tens of terabytes of memory for people scaling up, and Auto Scaling for people scaling out.
What to know first
What a server runs out of. Usually one of four: CPU (thinking), memory, disk, or network. Whichever runs out first sets the limit.
Vertical and horizontal. Other names for the same two ideas. Vertical scaling is scaling up. Horizontal scaling is scaling out.
How it works
- Scaling up: a bigger machine. More CPU cores, more memory, faster disks. Your code does not change at all, which is why it is usually the first thing to try.
- Up hits a ceiling. There is a biggest machine you can buy, and the largest ones cost far more for each extra bit of power. It is also still one machine: when it dies, everything stops (see Single points of failure).
- Scaling out: more machines side by side. Add ordinary servers next to each other. There is almost no ceiling, and losing one only removes a slice of power.
- Out needs your system to be ready. Something has to share visitors between the servers: a Load balancing balancer. And any server must be able to answer anyone, so servers cannot keep a visitor's data in their own memory: see Stateless services and sessions.
- Data is the hard part. Copying web servers is easy. Splitting a database across machines is much harder, which is why many teams scale the database up for as long as they can before splitting it. See Replication and Sharding and shard keys.
An example
One 8-core server answers 1,000 visitors a second. Traffic grows to 3,000.
Scale up: move to a 32-core machine. It handles about 3,500, with no code changes. But it costs much more than four small servers, and when it reboots the site is gone.
Scale out: run four 8-core servers behind a load balancer. Together they handle 4,000. If one dies, three still handle 3,000.
Next year traffic is 30,000. Up has no machine big enough; out just needs 30 or more servers.
Further reading
- Designing Data-Intensive Applications, chapter 1, Martin Kleppmann. The clearest introduction to scalability and load. The best book on this whole course. Start with this one.
- Stack Overflow: The Architecture, Nick Craver. A real, famous case for scaling up before scaling out.
- Scalability! But at what COST?, Frank McSherry and others. A short paper where one laptop beats big clusters. A good reminder not to scale out too early.