In previous part we have seen that how can we tune our operating system to get maximum performance for Hadoop, in this article I will be focusing on how to tune hadoop cluster to get performance boost on hadoop level
Tune Hadoop Cluster to get Maximum Performance (Part 2) – http://crazyadmins.com
Before I actually start explaining tuning parameters let me cover some basic terms that are required to understand Hadoop level tuning.
What is YARN?
YARN – Yet another resource negotiator, this is Map-reduce version 2 with many new features such as dynamic memory assignment for mappers and reducers rather than having fixed slots etc.
What is Container?
Container represents allocated Resources like CPU, RAM etc. It’s a JVM process, in YARN AppMaster, Mapper and Reducer runs inside the Container.
Let’s get into the game now:
1. Resource Manager (RM) is responsible for allocating resources to mapreduce jobs.
2. For brand new Hadoop cluster (without any tuning) resource manager will get 8192MB (“yarn.nodemanager.resource.memory-mb”) memory per node only.
3. RM can allocate up to 8192 MB(“yarn.scheduler.maximum-allocation-mb”) to the Application Master container.
4. Default minimum allocation is 1024 MB(“yarn.scheduler.minimum-allocation-mb”).
5. The AM can only negotiate resources from Resource Manager that are in increments of (“yarn.scheduler.minimum-allocation-mb”) & it cannot exceed (“yarn.scheduler.maximum-allocation-mb”).
6. Application Master Rounds off (“mapreduce.map.memory.mb“) & (“mapreduce.reduce.memory.mb“) to a value devisable by (“yarn.scheduler.minimum-allocation-mb“).
What are these properties ? What can we tune ?
Default value is 1024m
Sets the minimum size of container that YARN will allow for running mapreduce jobs.
Default value is 8192m
The largest size of container that YARN will allow us to run the Mapreduce jobs.
Default value is 8GB
Total amount of physical memory (RAM) for Containers on worker node.
Set this property= Total RAM – (RAM for OS + Hadoop Daemons + Other services)
Default value is 2.1
The amount of virtual memory that each Container is allowed
This can be calculated with: containerMemoryRequest*vmem-pmem-ratio
The heapsize of the jvm –Xmx for the mapper or reducer task.
This value should always be lower than mapreduce.[map|reduce].memory.mb.
Recommended value is 80% of mapreduce.map.memory.mb/ mapreduce.reduce.memory.mb
The amount of memory for ApplicationMaster
heapsize for application Master
The number of cores that a node manager can allocate to containers is controlled by the yarn.nodemanager.resource.cpu-vcores property. It should be set to the total number of cores on the machine, minus a core for each daemon process running on the machine (datanode, node manager, and any other long-running processes).
Default value – 100MB
This is very important property to tune, when map task is in progress it writes output into a circular in-memory buffer. The size of this buffer is fixed and determined by io.sort.mb property
When this circular in-memory buffer gets filled (mapreduce.map. sort.spill.percent: 80% by default), the SPILLING to disk will start (in parallel using a separate thread). Notice that if the splilling thread is too slow and the buffer is 100% full, then the map cannot be executed and thus it has to wait.
Hadoop uses buffer size of 4KB by default for its I/O operations, we can increase it to 128K in order to get good performance and this value can be increased by setting io.file.buffer.size= 131072 (value in bytes) in core-site.xml
Short-circuit reads – When reading a file from HDFS, the client contacts the datanode and the data is sent to the client via a TCP connection. If the block being read is on the same node as the client, then it is more efficient for the client to bypass the network and read the block data directly from the disk.
We can enable short-circuit reads by setting this property to “true”
Default value is 10.
Now imagine the situation where map task is running, each time the memory buffer reaches the spill threshold, a new spill file is created, after the map task has written its last output record, there could be several spill files. Before the task is finished, the spill files are merged into a single partitioned and sorted output file.
The configuration property mapreduce.task.io.sort.factor controls the maximum number of streams to merge at once.
Default value is 5
The map output file is sitting on the local disk of the machine that ran the map task
The map tasks may finish at different times, so the reduce task starts copying their outputs as soon as each completes
The reduce task has a small number of copier threads so that it can fetch map outputs in parallel.
The default is five threads, but this number can be changed by setting the mapreduce.reduce.shuffle.parallelcopies property
I tried my best to cover as much as I can, there are plenty of things you can do for tuning! I hope this article was helpful to you. What I recommend you guys is try tuning above properties by considering total available memory capacity, total number of cores etc. and run the Teragen, Terasort etc. benchmarking tool to get the results, try tuning until you get best out of it!!
The address and the base port on which the dfs NameNode Web UI will listen.
3. scp core-site.xml and hdfs-site.xml to slave.hadoop.com at /etc/hadoop/conf/
[root@slave ~]# sudo service hadoop-yarn-resourcemanager start
starting resourcemanager, logging to /var/log/hadoop-yarn/yarn-yarn-resourcemanager-slave.hadoop.com.out
Started Hadoop resourcemanager: [ OK ]
[root@slave ~]# sudo service hadoop-yarn-nodemanager start
starting nodemanager, logging to /var/log/hadoop-yarn/yarn-yarn-nodemanager-slave.hadoop.com.out
Started Hadoop nodemanager: [ OK ]
[root@master conf]# sudo service hadoop-mapreduce-historyserver start
starting historyserver, logging to /var/log/hadoop-mapreduce/mapred-mapred-historyserver-master.hadoop.com.out
15/04/25 02:56:01 INFO hs.JobHistoryServer: STARTUP_MSG:
STARTUP_MSG: Starting JobHistoryServer
STARTUP_MSG: host = master.hadoop.com/192.168.111.130
STARTUP_MSG: args = 
STARTUP_MSG: version = 2.6.0-cdh5.4.0
STARTUP_MSG: classpath =
STARTUP_MSG: build = http://github.com/cloudera/hadoop -r c788a14a5de9ecd968d1e2666e8765c5f018c271; compiled by 'jenkins' on 2015-04-21T19:18Z
STARTUP_MSG: java = 1.7.0_79
Started Hadoop historyserver: [ OK ]