Where Time Goes in a MapReduce Job
Number of Map Tasks
One map task is created per input split, normally one block. Too many tiny splits waste startup time; too few cut parallelism.
For many small files use CombineFileInputFormat (Hive does this with hive.input.format=CombineHiveInputFormat).
Number of Reducers
| Rule of thumb | Detail |
|---|---|
| Target size | Each reducer processes 1 to 2 GB of map output |
| Formula | 0.95 x nodes x containers per node (all reducers finish in one wave) or 1.75 x (two waves, better load balance) |
| Setting | mapreduce.job.reduces=<n> or -D mapreduce.job.reduces=50 on the command line |
Sort and Spill Settings
Look at counters: if Spilled Records is much more than Map output records, the buffer is too small and the job writes extra files to disk.
Compression of Map Output
| Codec | Speed | Ratio | Splittable? |
|---|---|---|---|
| Snappy | Very fast | Medium | No (use inside container formats like Parquet or ORC) |
| LZ4 | Very fast | Medium | No |
| Zstd | Fast | Good | No (inside formats) |
| Gzip | Slow | Good | No |
| Bzip2 | Slowest | Best | Yes |
Combiner and Data Skew
- A combiner runs a mini-reduce on each mapper's output, cutting shuffle data (only safe for associative and commutative functions like sum, count, max)
- Skew: one key has far more data, one reducer runs for hours. Check reducer durations in the History Server
- Fixes: add a salt to hot keys and aggregate twice, custom partitioner, filter junk keys such as NULL, use map-side joins for small tables
Speculative Execution and Uber Mode
Cluster-Level Utilisation
| Check | Healthy sign |
|---|---|
| YARN memory allocated vs actual use | Allocated close to used. Big gap = oversized containers |
| CPU utilisation on workers | 60 to 80 percent at busy times |
| Queue wait time | Low, no long pending lists |
| Container churn | Not many very short containers (startup overhead) |
| Failed or killed attempts | Low and explainable |
Tuning Order That Works
- Fix input: file formats and small files
- Right-size containers (heap about 80 percent)
- Choose reducers correctly
- Enable compression and combiner
- Fix skew
- Only then touch fine settings like sort factor
Conclusion
Tune MapReduce and YARN by controlling split size and reducer count, avoiding spills, compressing intermediate data, using combiners, fixing skew and keeping containers right-sized. Measure with counters and the history server.

