YARN stands for Yet Another Resource Negotiator. It is a powerful resource management system for a horizontal server environment. It is designed to be more flexible and generic than the original Hadoop MapReduce system, making it an attractive choice for companies looking to implement Hadoop. It allows companies to process data types and run various data processing engines on the same cluster, like Spark, Hive, Pig, etc.
One of the critical features of YARN is its ability to handle multiple types of workloads. This is achieved using two key components: the Resource Manager and the Node Manager. The Resource Manager allocates resources to different applications, while the Node Manager manages the resources on individual nodes in the cluster.
YARN has many applications and use cases, including batch processing, interactive SQL, real-time streaming, machine learning, graph processing, long-running services, and big data processing.
Learning Objectives:
1. Advantages and Disadvantages of YARN
2. Applications and Use Cases of YARN
3. Learn the Difference: YARN vs. Map Reduce
4. Understanding the Concept With Basic Code Examples
5. Conclusion
There are benefits to using YARN for extensive systems, but it has many disadvantages too. Below are some of the pros and cons.
It has many applications and use cases that are highly beneficial for current tech giants. Some of them are discussed below.
This section will discuss the difference between YARN and Map Reduce.
YARN | Map Reduce |
1. YARN (Yet Another Resource Negotiator) is a resource management system for Hadoop that was introduced in Hadoop 2.0. | 1. MapReduce is a programming model and software framework for processing large data sets in parallel. |
2. YARN is responsible for managing resources, such as CPU and memory, in a Hadoop cluster and scheduling tasks to execute those resources. | 2. MapReduce is responsible for processing the data and generating the results. |
3. YARN has a centralized architecture that allows for better scalability and resource management, while MapReduce has a more decentralized architecture. It provides more flexibility regarding how resources are allocated and used. | 3. MapReduce is more rigid in resource allocation and usage. |
4. YARN allows for real-time processing of data streams, while MapReduce is mainly used for batch processing of data. It also allowed for better cluster utilization and increased performance. | 4. MapReduce can lead to underutilization of resources and lower performance in some cases |
This section will discuss some basic examples that beginners can easily understand, like running a simple word count job using YARN and MapReduce or running a Pig script using YARN.
Example 1: Running a simple word count job using YARN and MapReduce:
$ hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /input/text.txt /output/wordcount
In this example, we are using the built-in wordcount example job that comes with Hadoop. We pass two arguments, the input file /input/text.txt and the output directory /output/wordcount, where the job results will be stored. This job will count the number of occurrences of each word in the input text file and write the results to the output directory.
Example 2: Running a Pig script using YARN:
$ pig -x yarn -f /path/to/pig/script.pig
In this example, we use the Pig command-line interface to run a Pig script located at “/path/to/pig/script.pig” on a YARN cluster. The “-x yarn” option tells Pig to use YARN as the execution mode. This can be used to run Pig scripts that perform data processing, data cleaning, and data transformation tasks.
Example 3: Running a Hive query using YARN:
$ hive -e "SELECT * FROM mytable LIMIT 10"
In this example, we use the Hive command-line interface to run a SQL-like query on a table named “mytable.” The query selects all columns and rows from the table and returns only the first ten rows. The results of the question will be printed on the console. This can be used for interactive data querying and exploration.
Example 4: Running a Spark job using YARN:
$ spark-submit --class org.example.MySparkJob --master yarn --deploy-mode client --executor-memory 512m --num-executors 10 /path/to/jar/my-spark-job.jar arg1 arg2
In this example, we are using the Spark command-line interface to submit a Spark job named “MySparkJob” that is packaged in a jar file located at “/path/to/jar/my-spark-job.jar”. The job takes two arguments, “arg1” and “arg2”, passed to the main method. The “–master yarn” option tells Spark to use YARN as the cluster manager. “–deploy-mode client” means spark to run the driver program on the client machine, and “–executor-memory 512m” and “–num-executors 10” are used to configure the amount of memory per executor and the number of executors respectively.
In conclusion, YARN is a powerful resource management system for Hadoop. It allows different types of data processing workloads, such as batch processing, interactive queries, real-time streaming, and machine learning, to run on the same cluster. It gives a centralized management system for a Hadoop cluster, making it easier to manage and monitor resources. However, it’s important to note that it has limitations, such as added complexity, inefficiencies in resource allocation, and limited support by specific frameworks and tools.
Key takeaways of this article:
1. Firstly, we have discussed the YARN framework. It is a resource management system for large-scale distributed computing in Hadoop that allows multiple data processing frameworks to run on the same cluster.
2. Then, we discussed the advantages and disadvantages of using it. We have discussed scalability, the benefits of cluster-making, etc.
3. After that, we discussed its use cases and wrote the code of some of its primary applications, like using a pig script or running a simple command for word count.
The media shown in this article is not owned by Analytics Vidhya and is used at the Author’s discretion.