MapReduce
medium 30 minMapReduce 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 hear | Say | Because |
|---|---|---|
| Count or group petabytes overnight | Map, shuffle by key, reduce | The work divides by key |
| Build a search index from all pages | Batch job by word | An inverted index is one shuffle |
| Rebuild the numbers from raw events | Batch over stored events | Deterministic, so it can run again |
| Show it within a second | Not a batch job | It ends when the whole input is done |
| 20 GB of data | One machine | A 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.