Book Deep-Read · Software Engineering at Google · Chapter 25

Compute as a Service

Software Engineering at Google · Ch 25 · Compute as a Service · Onufry Wojtaszczyk · 2020

中文 →

What is this chapter about?

Once the code is written, some computer has to run it. This chapter is about that deceptively simple wish — "just give me some machines to run my stuff" — and what it grows into at a company with tens of thousands of engineers and millions of machines. Google's internal system for this is called Borg; the Kubernetes you hear about everywhere is its open-source descendant.

A strange fact first

Google engineers usually don't know, and don't care, which machine their program runs on. The system may stop it at any moment and restart it somewhere else — and that is considered normal, not an incident.

Why the old world was hard

The early way was a craft workshop: copy the program onto machines one by one, log in to each to start it, and watch each one. In 2002 Jeff Dean called running one data job a "logistical nightmare": find 50+ machines, start and babysit each; if one died, nobody picked up its work automatically; and people fought over machines using a hand-edited "sign-up" file. More machines meant more tired people.

How it works, intuitively

What it brings / how to choose

The win: however big you grow, the people managing machines don't have to double. But programs must be written differently — they can't keep their only copy of data on the local machine, because they may be moved at any time. As for which platform — your own machines, rented virtual machines, a container platform, or "serverless" where you don't even see servers — there is no single answer: the less you manage, the less you can tweak, and once chosen, it is hard to switch.

One line to remember

Treat machines as replaceable cattle: hand them to one shared scheduler, and write programs that don't mind being moved — the bigger you get, the better the deal.

Want to see how Borg grew out of a hand-edited sign-up file, why batch jobs ride "for free" on serving slack, how five-digit PIDs caused an eight-year cleanup, and when serverless is the right call? → Switch to Deep