โ Back to Amazon EC2 and Auto Scaling
๐ Amazon EC2 and Auto Scaling: cheat sheet
๐จ The analogyHiring food trucks for a festival, with a manager who keeps the right number serving and replaces any that break.
๐ The regular explanationRented virtual machines in the AWS cloud, booted from an image with a chosen type, storage and pricing model, and kept at the right healthy count across Availability Zones by an Auto Scaling group.
- You call the truck hire yard and ask for one truck.
- The yard finds a free truck and parks it on the field. A few minutes later its engine is running.
- You climb in and start serving. You pay for the time you have the truck.
- At night you switch the truck off. You stop paying for the truck itself, and you can start it again tomorrow.
- When the festival is over, you hand the truck back. It's gone for good.
- The order form says which model and size to send, and which fit-out plan to kit each truck from.
- You hand the yard the form and ask for two trucks.
- Both trucks are kitted out from the same plan, so they come out exactly alike.
- New menu. You write version 2 of the form, and the next truck arrives with the new menu. The first two keep the old one until they're swapped.
- Truck 1 keeps quick snacks in its built-in fridge and the stock that matters in your cool box, plugged in.
- You restart the engine. Nothing is lost from the fridge or the cool box.
- The truck goes back to the yard. The yard empties its fridge, but your cool box stays on the field.
- A new truck arrives in the same field. You wheel the cool box in and the stock is all there. Its own fridge starts empty.
- Three trucks, three ways to pay. Full price with no promise, a discount for promising a year or three, and a cheap spare truck.
- The yard needs its spare truck back. It gives you a two-minute warning.
- You finish the orders in hand and write down where you got to. Then the yard takes the truck.
- Another spare truck from a different part of the yard takes over from where you wrote down. The other two trucks never noticed.
- The manager's note says at least 2 trucks, aim for 3, at most 6. They order 3 and spread them over two fields.
- The manager keeps checking on every truck. All three are fine.
- Truck 3 breaks down. When the manager checks on it, it doesn't answer.
- The manager sends truck 3 back and orders a fresh truck for the same field, from the same order form.
- Then all of field B loses power. The manager orders a truck in field A, which still has power, so three trucks keep serving.
- The steward sends each customer to a truck with room. The manager's rule is to keep every truck about half busy.
- Lunch rush. Many more customers arrive and both trucks get far too busy.
- The manager sees it and orders a third truck.
- The steward checks the new truck is ready, then starts sending customers to it. Every truck is about half busy again.
- After lunch it's quiet. The steward stops sending new customers to truck 3, and it serves the people already in its queue.
- Then the manager sends truck 3 back.
๐งฉ Key questions
- You keep today's orders only in the truck's built-in fridge, then switch the truck off for the night. What's there in the morning?
- Nothing: the yard empties that fridge when the truck is switched off or handed back. Only a restart of the engine keeps the fridge full. Stock that matters belongs in a cool box.
- Your cool box is in field A. Can you wheel it straight into a truck in field B?
- No: pack a copy into the warehouse and fill a new cool box in field B. A cool box only fits trucks in its own field.
- The yard gives your spare truck a two-minute warning. What does that tell you about using spare trucks?
- Use them for work that can stop and carry on in another truck. Spare trucks are cheap because the yard can take them back at short notice.
- One truck breaks down. The manager's note says aim for 3. What does the manager do?
- Sends the broken truck back and orders a fresh one from the order form. The manager keeps checking every truck and always tops back up to the number on the note.
- At the lunch rush every truck is far too busy, and the rule is about half busy. What happens next?
- The manager orders another truck, up to the most on the note, and the steward sends customers to it once it's ready. More trucks share the queue, so each one is about half busy again.