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
Memory card and where the analogy breaks
3 min read+10 XP
The memory card (tear this page out)
| # | Question | Memory code |
|---|---|---|
| 6.1 | What is scaling? | Scaling is staying fast when the crowd grows |
| 6.2 | Vertical scaling? | Bigger chef, same kitchen, same ceiling |
| 6.3 | Horizontal scaling? | More chefs, but only if the work can be split |
| 6.4 | Why stateless? | Any chef can cook any order |
| 6.5 | Where does state go? | Nothing important lives in a chef's head |
| 6.6 | Autoscaling? | Scale out fast, scale in slow, and schedule what you know |
| 6.7 | The database? | Fix, cache, grow, copy, split |
| 6.8 | Cost? | Pay for the rush only during the rush |
| 6.9 | Which to choose? | Scale up to start, scale out to grow, and always keep two |
The whole chapter in one line: Keep the chefs forgetful, hire before the rush, and climb the pantry ladder one step at a time.
Where the analogy breaks
- New chefs walk in ready to cook. New servers need minutes to start and often start with cold caches, so they're slower at first.
- Chefs can shout to each other across the kitchen. Servers talk over a network, which is slower and can fail, so splitting work across machines adds delays the kitchen never has.
- A pantry runs out of rice in an obvious way. A database slowly gets slower as load grows, until it suddenly falls off a cliff (Chapter 5, section 5.8).
Quick check
Five questions on this chapter. Pick an answer, then check it.
quiz