CS PAPERS DEEP-READ · PAPER 59

Borg: A Datacenter as One Machine

Verma, Pedrosa, Korupolu, Oppenheimer, Tune, Wilkes · Google · EuroSys 2015

中文 →

What did this paper do?

In 2015 Google published the first systematic account of Borg — a system that had already been quietly running inside the company for over a decade, deciding which machine every Google program (Search, Gmail, ads, data analysis) runs on. Kubernetes, which you have probably heard of, is essentially Borg's ideas rewritten and open-sourced.

What Borg does fits in one sentence: it treats the thousands of machines in a datacenter building as one giant machine to hand out. You no longer say "give me machine 3 and machine 7"; you say "run 500 copies of this program, each needing roughly this much compute and memory."

How wasteful the old world was

Before Borg — and still, in many companies today — each team fenced off its own pile of machines. Two problems follow. Every pile has to be bought for its busiest moment, so most of the time it sits idle. And the piles can't lend to each other: while the ads machines are bored at 3am, the reporting jobs queued up next door still can't touch them.

An analogy: an office building assigns each company its own floor and forbids anyone from using another floor's meeting rooms. Every floor must then keep a room big enough for an all-hands — a meeting that happens twice a year.

The idea: mix two workloads with opposite temperaments

The work running on those machines comes in two kinds with opposite personalities. Online services (web search, email) must stay up, and users feel it immediately when they slow down — but their load swings wildly across the day. Batch jobs (crunching data, building reports) run for minutes or hours and then vanish; nobody minds if they're slow, and re-running them is fine.

Borg's core move is to run both kinds on the same machines, letting batch jobs eat whatever the online services aren't using right now. Back to the building: meeting rooms are no longer assigned — you just book one. But meetings have ranks: when a real client arrives, the internal brainstorm inside has to clear out.

So how does it keep the online services safe?

First, ranks. Every piece of work carries a priority. When machines get tight, Borg simply kicks the low-priority work out and hands the space to the high-priority work; the evicted batch job queues up for the next round — it can just re-run.

Second, watch real usage and take back what isn't used. Engineers almost always ask for more than they need, out of fear of running short. Borg doesn't quite trust that number: it keeps watching how much you actually use, draws a line a safe margin above that, and lends the gap between that line and your request to batch jobs. When your usage really does climb, it takes the loan back.

Third, it repairs itself. At ten thousand machines, some break every day. Borg listens to every machine's heartbeat; when one goes silent, the work on it restarts elsewhere automatically.

What it bought

Google did the arithmetic: splitting online services and batch jobs onto separate machines would make a median-sized datacenter buy 20–30% more machines. More lasting is the habit it established — you describe what you want, not where it runs — which is how essentially every cloud and every Kubernetes cluster works today. One honest note on the price: this bargain is paid for by batch jobs accepting that they may be killed at any moment, so such programs must tolerate being cut off halfway and starting over.

Remember one thing

Treat the whole building as one machine: you say what you want, not where it runs. Online services and batch jobs are mixed onto the same machines, and utilization is squeezed up by priority-based eviction plus reclaiming the resources you asked for but never used, with failed machines replaced automatically — saving 20–30% of the fleet, and defining what Kubernetes would later look like.

Want the architecture diagram, how the scheduler picks one machine out of ten thousand, and the measured numbers? → Switch to the deep read