Lab · Architecture patterns

Batch jobs: map, shuffle, reduce

A job counts clicks per country across 8 input files. Mappers read the files, the shuffle sends each country to one reducer, and reducers add up the totals. Add a combiner, make one country hot, or slow one worker, and watch the job time.

Try it

Lab time 3.0 s
Input files, 8 files of 400Input files8 files of 400Mappers, 0 of 4 busyMappers0 of 4 busy8 of 8 mappedShuffle, every recordShuffleevery recordReducers, 4 reducersReducers4 reducersreducingCounts, per countryCountsper country
  • Input files — 8 files of 400 — healthy
  • Mappers — 0 of 4 busy — healthy — 8 of 8 mapped
  • Shuffle — every record — healthy
  • Reducers — 4 reducers — healthy — reducing
  • Counts — per country — healthy
  • A file read by a mapper
  • Map output, or the final counts
  • Records shuffled to a reducer
Phase
Shuffle and reduce
job 1
Last job time
—
Records shuffled
—
in the last job
Busiest reducer
—
of the records shuffled
Backup tasks
—
in the last job

Numbers add up:8 map task copies = 8 finished + 0 killed + 0 running; every job's counts add up to 3200The lab checks this sum as it runs, so a counting mistake would show here.

Controls

The job (applies from the next job)
4
4

Each mapper adds up its own counts before the shuffle.

Trouble (also from the next job)
20%

Every click from that country goes to the same reducer.

Mapper 1 runs 4 times slower.

A free mapper runs a backup copy of a task that is running long; the first copy to finish wins.

Reducers (this job)

ReducerCountriesRecords receivedStatus
1GB, ID, MX692done
2BD, BR, NG, US939reducing
3DE, IN, JP1145reducing
4FR, PK424done

Recent jobs

JobTimeMap phaseShuffledBusiest reducerSettings

What just happened

  1. 0.0sInfo: Job 1 starts: 8 splits on 4 mappers, 4 reducers.
What this model simplifies
  • Time is slowed so you can watch each task. A map task here reads 400 records in 0.8 s; real jobs read gigabytes per task.
  • Reduce starts only when every map task is done. Real frameworks start fetching map output early, but still cannot finish a reducer before the last map task.
  • A backup copy is only considered when a mapper becomes free. Real schedulers check running tasks on a timer.
  • Workers never crash here. A real framework reruns a failed task elsewhere, which is why map and reduce steps must be safe to repeat.