AlgoViz

MapReduce

medium 30 min

MapReduce processes very large data on many machines with two small functions.

Remember it

The few things worth knowing cold, and how to make them stick.

Memory hook

MSR: Map transforms, Shuffle groups by key, Reduce aggregates.

Three people sort four shells each, count their own, carry the cards to one table per kind, and each table adds its cards.

Cheat sheet

You write
map, reduce, maybe a combiner
Partition
hash(key) mod R
Map output
local disk
Final output
replicated files
Usual bottleneck
shuffle
Straggler
backup task
Skew
combine, salt, map-side join
Paper
2004
HDFS block
128 MB by default

Spot it when you see

  • Group or count over terabytes.
  • Waiting is fine.
  • The work divides by key.

Tricks that stick

  • Like a kitchen: chop, sort into bins, cook.
  • Like helpers who tally books in a library, then merge the tallies by word.
  • Divide, work in parallel, combine.
  • Sum and count travel; averages do not.

Do not forget

  • Averaging averages.
  • Side effects inside tasks.
  • More reducers against one hot key.
  • A cluster for data that fits on a laptop.