6. Vertical vs Horizontal Scaling
1
The picture to keep in your head2
6.1 What does "scaling" actually mean?3
6.2 What is vertical scaling?4
6.3 What is horizontal scaling?5
6.4 Why does scaling out need stateless servers?6
6.5 If servers are stateless, where does the state go?7
6.6 What is autoscaling, and how do you get it right?8
6.7 What about the database? Why is it the hardest part to scale?9
6.8 What does each kind of scaling really cost?10
6.9 So when do you choose which?11
Memory card and where the analogy breaks12
Practice: five levels13
Interview questions14
Solutions15
Sources16
Code lab6. Vertical vs Horizontal Scaling
6.1 What does "scaling" actually mean?
3 min read+10 XP
In the kitchen: A kitchen "scales" if it can serve twice the diners and the food still comes out hot and on time, without the bill for running it going crazy. Serving twice the diners with an hour's wait doesn't count.
In the system: Scalability is the ability to handle more load (requests, users, data) while keeping latency and errors within your targets, at a reasonable cost, usually by adding resources.
Three things to keep apart:
- Performance vs scalability. Performance is how fast the system is for one user. Scalability is whether it stays that fast as users grow. A system can be quick for 10 users and collapse at 10,000.
- What's growing. Traffic (requests a second), data (terabytes stored), or both. They often need different fixes: more app servers for traffic, sharding for data (Chapter 15).
- Up or out. You can add resources by making one machine bigger (6.2) or by adding machines (6.3).
For the Book Fest, "scaling" means: at 20,000 requests a second, the book page still loads within its latency target (Chapter 5) and checkout doesn't fail.
Memory code: "Scaling is staying fast when the crowd grows."