Lesson 1 of 16
6. Vertical vs Horizontal Scaling

The picture to keep in your head

3 min read+10 XP

Every question below is answered twice: first in the kitchen, so you can picture it, then in the system, so you know exactly how it works. Each answer ends with a memory code to lock it in.

The picture to keep in your head

A restaurant gets famous and the orders double. The owner has two choices. Hire one superstar chef with four hands and a giant stove, or hire more ordinary chefs who work side by side. The superstar is simple: nothing about the kitchen changes. But there's only so big one chef can get, and if they fall sick, nobody cooks. More chefs can grow almost without limit, but only if the orders and recipes aren't stuck in one chef's head. And all of them still share one pantry.

That's vertical scaling (a bigger machine) and horizontal scaling (more machines).

Our running example: the bookstore from the last three chapters is planning its yearly Book Fest sale. Normal evening traffic is about 2,000 requests a second. During the sale it's expected to hit 20,000, ten times more, for a few hours. (These are assumptions for the example.)

In the kitchenIn the system
A chefA server
A bigger, faster chef with a bigger stoveVertical scaling (scale up): more CPU, RAM, disk
More chefs working side by sideHorizontal scaling (scale out): more servers
The head waiter handing out ordersLoad balancer (Chapter 7)
Orders on a shared board, not in a chef's headState in a shared store, not on the server
Extra chefs hired for the dinner rushAutoscaling
The one pantry everyone sharesThe database

the kitchen mapped to servers, scaling up, scaling out, shared state, autoscaling and the database.

Figure: the kitchen, mapped to the system. More chefs only help if the orders and recipes aren't stuck in one chef's head.