YARN and MapReduce Performance Tuning

Big Data and Hadoop Administrator 15 min min read Updated: Nov 17, 2026 Advanced
YARN and MapReduce Performance Tuning
Advanced Topic 2 of 3

Where Time Goes in a MapReduce Job

text submit -> AM start -> map tasks (read, map, sort, spill, merge) -> shuffle (copy) -> reduce (merge, reduce, write) Common slow places: too many tiny tasks | skewed reducers | spill to disk | slow nodes | network shuffle

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.

xml <property><name>mapreduce.input.fileinputformat.split.minsize</name><value>268435456</value></property> <!-- 256 MB: fewer, bigger mappers --> <property><name>mapreduce.input.fileinputformat.split.maxsize</name><value>536870912</value></property>

For many small files use CombineFileInputFormat (Hive does this with hive.input.format=CombineHiveInputFormat).

Number of Reducers

Rule of thumbDetail
Target sizeEach reducer processes 1 to 2 GB of map output
Formula0.95 x nodes x containers per node (all reducers finish in one wave) or 1.75 x (two waves, better load balance)
Settingmapreduce.job.reduces=<n> or -D mapreduce.job.reduces=50 on the command line

Sort and Spill Settings

xml <property><name>mapreduce.task.io.sort.mb</name><value>512</value></property> <!-- buffer for map output; must fit in container heap --> <property><name>mapreduce.map.sort.spill.percent</name><value>0.80</value></property> <property><name>mapreduce.task.io.sort.factor</name><value>64</value></property> <!-- streams merged at once --> <property><name>mapreduce.reduce.shuffle.parallelcopies</name><value>20</value></property>

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

xml <property><name>mapreduce.map.output.compress</name><value>true</value></property> <property><name>mapreduce.map.output.compress.codec</name><value>org.apache.hadoop.io.compress.SnappyCodec</value></property> <property><name>mapreduce.output.fileoutputformat.compress</name><value>true</value></property> <property><name>mapreduce.output.fileoutputformat.compress.codec</name><value>org.apache.hadoop.io.compress.ZStandardCodec</value></property>
CodecSpeedRatioSplittable?
SnappyVery fastMediumNo (use inside container formats like Parquet or ORC)
LZ4Very fastMediumNo
ZstdFastGoodNo (inside formats)
GzipSlowGoodNo
Bzip2SlowestBestYes

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

xml <property><name>mapreduce.map.speculative</name><value>true</value></property> <property><name>mapreduce.reduce.speculative</name><value>false</value></property> <!-- often off for reducers --> <property><name>mapreduce.job.ubertask.enable</name><value>true</value></property> <!-- tiny jobs run inside the AM container -->

Cluster-Level Utilisation

CheckHealthy sign
YARN memory allocated vs actual useAllocated close to used. Big gap = oversized containers
CPU utilisation on workers60 to 80 percent at busy times
Queue wait timeLow, no long pending lists
Container churnNot many very short containers (startup overhead)
Failed or killed attemptsLow and explainable
bash # find long jobs and their resource use mapred job -list all | head yarn application -status application_1731700000000_0300 mapred job -history job_1731700000000_0300 | head -40 # see the counters of a finished job mapred job -status job_1731700000000_0300

Tuning Order That Works

  1. Fix input: file formats and small files
  2. Right-size containers (heap about 80 percent)
  3. Choose reducers correctly
  4. Enable compression and combiner
  5. Fix skew
  6. Only then touch fine settings like sort factor
Work with users: Most big gains come from better jobs (partitioning, file format, filter early), not from cluster settings. Offer a short best-practice guide and review the top 10 resource-consuming jobs each month.

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.

Quick Summary: splits, reducers ~1-2 GB, sort buffer, compression, skew.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators