intermediatebig-data

MapReduce

Break the job into 'map' and 'reduce' steps, and let the cluster run them in parallel.

Key Points

What it is

MapReduce is a programming model for processing large datasets in parallel across a cluster, structured around two steps: 'Map,' which processes and transforms each piece of data independently, and 'Reduce,' which aggregates the mapped results into a final output.

Why it exists

Writing custom distributed code to coordinate many machines, handle failures, and combine results is extremely hard to get right. MapReduce exists to give developers a simple, standardized two-step pattern (map, then reduce) so they can write distributed jobs without manually handling cluster coordination themselves.

Intuition

To count how many times each word appears across a warehouse full of books, hand each worker a stack of books (Map: each worker tallies words in their own stack independently). Then, have workers combine their tallies by word — everyone with 'the' tallies hands their numbers to one person to sum (Reduce: aggregate by key). No worker ever needs to see the whole warehouse at once.

How it works

  1. Split input

    The large dataset is split into chunks distributed across the cluster.

  2. Map

    Each chunk is processed independently and in parallel, producing intermediate key-value pairs.

  3. Shuffle and sort

    All values sharing the same key are grouped together across the cluster, regardless of which machine produced them.

  4. Reduce

    Each group of values for a key is aggregated into a final output value, e.g. a total count or sum.

When to use

When not to use

Common mistakes

In practice

Rarely written directly anymore in new pipelines, but understanding it is essential context for why Spark exists and how distributed batch processing conceptually works under the hood.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

hadoop-ecosystemhdfsapache-spark-introspark-transformations-actions
Chirp at me!