IT PAPER DEEP-READ · PAPER 18

MapReduce: Shrinking "Massive Parallelism" to Two Functions

Jeffrey Dean & Sanjay Ghemawat · Google · OSDI 2004

中文 →

What did this paper do?

In 2004, two Google engineers published a recipe called MapReduce for one nagging problem: you have a huge pile of data to crunch, one machine can't finish it, so it has to be spread across thousands of machines. The catch is that "getting a thousand machines to cooperate on one job" is brutally hard to write — who gets which slice of data, what happens when a machine dies mid-computation, how do you glue the fragments back together. Writing that plumbing is more work than the actual algorithm. MapReduce's contribution: package all that plumbing away once, and leave you just two blanks to fill in. It went on to directly spawn the open-source Hadoop and the whole "big data" era.

First, the painful chore

Say your boss asks you to count, across Google's entire crawled copy of the web, how many times each word appears. The logic couldn't be simpler — scan start to finish, tally one for every word you see. But the data is tens of terabytes; one machine would scan until the heat death of the universe. So you split it across a thousand machines, count separately, and merge a thousand little tallies into one big one. The real torture isn't the counting — it's "how do I spread this safely across a thousand machines": how to slice it, how to distribute it, who covers for a machine that drops offline, how to gather the results. Every new big-data job forces you to clean up that same mess all over again.

The idea: you fill in just two blanks

MapReduce says: jobs like this can all be broken into the same two steps. Just spell out those two steps and I'll handle everything else.

Step one, "Map" (process in parallel): tell me, given one small slice of data, what "label → value" slips you want to emit. For word counting: for each word you see, emit one (that word, 1). Step two, "Reduce" (roll up by label): tell me, once I've gathered all the slips carrying the same label, how you want to fold them into one answer. For word counting: sum up the pile of 1s a given word received. You write only these two "how-tos"; who does the work, what happens when it breaks, how slips get grouped by label — the framework does all of it.

Why is it fast and failure-proof?

A few plain but potent tricks. One: on failure, just recompute that one small piece. A "foreman" watches over thousands of "workers"; when a worker dies mid-task, the foreman simply reassigns that small piece to someone else — no need to tear the whole job down. Machines break daily, and it runs right through. Two: send the work to where the data already is. The data already lives scattered on these machines' disks, so the framework tries to make "the worker that processes a chunk" be the very machine that stores that chunk, saving enormous network hauling. Three: rescue the stragglers. Among a thousand workers a few always sit on flaky machines and crawl, dragging the whole job's finish line out; near the end the framework hands those slow pieces to a second worker to race, and takes whichever finishes first — which cuts total time dramatically.

What it gave us

MapReduce took "write a large-scale program that runs on thousands of machines and survives them breaking at random" — once the province of distributed-systems wizards — and turned it into filling in two functions any engineer can write. Google was soon running thousands of such jobs internally, and even rewrote its search index with it. The open-source world cloned the idea into Hadoop, and nearly the whole "big data" industry was built on this line of thinking. The honest cost: it's only good at batch work — "scan a huge pile of data front to back." Ask it to iterate repeatedly, or answer in real time, and it turns clumsy — which is exactly what later systems like Spark set out to fix.

Remember it in one line

Take the misery of "getting thousands of machines to cooperate on crunching a mountain of data" and shrink it to two functions you fill in: Map (process in parallel, turning data into "label → value" slips) and Reduce (roll the slips up by label into an answer). Who computes, how failed machines are covered, how stragglers are rescued, how results are stitched together — the framework does it all. That let ordinary people write massive parallel programs, and opened the big-data era.

Want the execution-flow diagram, the fault-tolerance and "race-the-straggler" mechanics, and real-cluster numbers sorting 1 TB? → Switch to the deep read