AlgoViz

MapReduce

medium 30 min

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

When it comes up

The moments this idea belongs in a design interview, and the moments it does not.

Signals

When to bring it up

You hearSayBecause
Count or group petabytes overnightMap, shuffle by key, reduceThe work divides by key
Build a search index from all pagesBatch job by wordAn inverted index is one shuffle
Rebuild the numbers from raw eventsBatch over stored eventsDeterministic, so it can run again
Show it within a secondNot a batch jobIt ends when the whole input is done
20 GB of dataOne machineA cluster would be slower

Options

Compare your moves

Count views per video for a day. One video has 40% of all views. How?

BreaksMore reduce tasks
How
Go from 100 to 1,000 reducers.
Limit
The large video is still one key on one reducer.
Choose when
Many medium keys, no giant.
WorksSalt the key
How
Split each video over ten salted keys and add ten results in a second job.
Limit
A second job for a sum that did not need it.
Choose when
The operation cannot be combined early.
StrongCombiner
How
Each map task sends one count per video.
Limit
Only for operations that combine, and distinct viewers need a mergeable sketch.
Choose when
Sums, counts, maximums, minimums.