CHAPTER DEEPREAD · SRE · CH 25

Data Processing Pipelines

Site Reliability Engineering · Ch 25 · Google · 2016

中文 →

What is this chapter about?

The "recommended for you" row on your phone, your end-of-month statement, the ordering of your search results — none of that is computed the instant you open the app. Somewhere, overnight, a production line is grinding mountains of raw records into those finished goods. Chapter 25 of Google's SRE book is about why that line keeps breaking, and what to do about it.

An analogy

Picture a central kitchen. At three in the morning an alarm goes off, everyone clocks in at once, and the day's ingredients get washed, chopped, cooked and boxed before dawn. Sounds orderly. Then it grows, and every kind of trouble arrives.

Four ways the 3 a.m. shift goes wrong

One pot holds up the whole floor. The work is split between a hundred cooks. Ninety-nine finish in ten minutes; the last one was handed an entire cow and needs three hours. Because the next step can't start until everybody is done, the whole line just waits — and hiring another hundred cooks changes nothing. The problem isn't too few hands, it's work that was divided unevenly.

The storeroom gets mobbed at the bell. The alarm rings and a thousand cooks charge the storeroom at the same instant, jamming the door. They can't get in — and neither can the restaurant next door, which had nothing to do with any of this.

Occasional collisions. There's a second line upstairs. One starts every three hours, the other every four. Mostly they miss each other, but every twelve hours they land on the same moment, and that's the time something breaks. Afterwards you investigate and each line, examined on its own, looks perfectly fine.

You can't tell alive from stuck. From across the room the kitchen lights are on and figures are moving. You genuinely cannot tell whether they are cooking or standing around. By the time you find out, it's usually the customers who noticed first that no food arrived.

Google's answer: stop clocking in on a schedule

Change the arrangement: the line never opens and closes — it simply stays on. Work arrives, someone picks it up. In the middle sits a dispatch desk that records who has which job and how far along it is. The peaks flatten out, the storeroom stops getting mobbed, and for the first time you can see exactly which step a job is stuck on.

What the numbered ticket is for

One detail is especially neat. When a cook takes a job, they also take a numbered ticket. Suppose they drop out of contact for half a minute; the dispatch desk assumes they're gone and hands that dish to someone else. When the first cook comes back and tries to hand in the plate, their ticket is void and the desk refuses it. So the same dish never reaches a table twice. The desk itself is duplicated across several sites, too — one site loses power, another keeps dispatching.

The honest cost: "always on plus numbered tickets" is far more machinery than "an alarm clock and a script." If your job is modest and running it once a day is genuinely enough, the old way is less trouble.

One thing to remember

The enemy of a data pipeline is usually not the volume of data but the act of clocking in on a schedule — which inevitably produces idle troughs, crushing peaks, and a middle where you can't tell alive from stuck. Past a certain size, leave the line running, and give every job a numbered ticket.

Want the mechanisms, the diagrams and the trade-off tables? → Switch to the deep read