BOOKS DEEP-READ · GOOGLE SRE · CH 18

Software Engineering in SRE

Site Reliability Engineering · Ch 18 · Google · 2016

中文 →

What is this chapter about?

When you check out on Black Friday and the site doesn't fall over, something unglamorous made that possible: months earlier, somebody worked out how many machines to buy and which buildings to put them in. That job is called capacity planning. Chapter 18 of Google's SRE book is about how they handed that chore to a program.

A strange thing first

The whole book is about running production systems well. This one chapter suddenly changes register: it's about the operations team writing a real software product. That sounds like a distraction — why should the fire brigade open a factory? Because some chores take a week by hand and are stale the moment you finish. Only by turning one into software does that week of effort accumulate into anything.

Why the old way was hard

The old way was an enormous spreadsheet: this service gets this much in that building, cell by cell, then a round of meetings to sign it off. The trouble is that the sheet records conclusions, not reasons. Change one assumption — growth came in faster, a batch of machines is two months late, a launch slipped — and the whole sheet has to be filled in again. The previous week's work is gone. Tired people start padding their numbers, because too many is safer than too few. That's how the money burns.

The idea: hand over conditions, not answers

The idea is plain. When you brief a builder, "three lights in the living room" is worse than "the living room must be bright enough, the switch goes by the door, and the whole job stays under budget." The first one has to be rewritten the moment the house changes; with the second, the house can change and not a word of your brief moves — the plan recalculates itself.

Google did exactly that. Instead of handing over "50 machines in building A," they wrote down the conditions: this service must absorb the traffic we expect, it must survive losing a whole building and still keep two spare copies, it must sit near its users, and the total bill should be as small as possible. Then a program that is good at puzzles takes over: it treats every condition as a rule that must hold at once, and picks the cheapest arrangement inside those rules. When an assumption changes, you re-run it — a new plan in minutes, and nobody fills in a sheet.

What it costs

One honest caveat: if you leave a condition out, the program will not warn you. It will simply give you the cheapest answer in the gap you left — forget to say "keep spare copies" and it will keep none. So the human work doesn't disappear. It moves from filling in cells to thinking clearly about what you actually require.

Remember one thing

Rather than recomputing "how many machines" by hand, write down why that many and let a program do the arithmetic. Answers go stale; conditions don't. And the reason the ops team should write this software themselves is that only the people who use it daily know how to state the conditions.

Want the mechanisms, the notation and the diagrams? → Switch to the deep read