Many applications and teams
sharing the same machines.
YARN arbitrates the cluster's memory and CPU among applications and divides them into queues with guaranteed capacity, so that different engines and teams share the same machines. Follow an application from submission to completion and see what happens when a component fails.
Resource management divides a cluster's memory and CPU among the applications that run on it. In TDP Datacenter, this work belongs to Apache YARN, on top of which MapReduce, Tez, Spark and Flink, among others, run.
One arbiter
The ResourceManager decides
A single authority for the entire cluster arbitrates resources among all applications and allocates to each one the containers it requests.
One manager per application
The ApplicationMaster negotiates
Each application has its own ApplicationMaster, which requests containers and tracks their state and the progress of the work.
One agent per machine
The NodeManager executes
On each machine, the NodeManager starts the containers, monitors the resource usage of each one and reports to the ResourceManager.
On this page
- Watch an application run
- Architecture
- From cluster to container
- When something fails
- Two ResourceManagers, one active
- Application history
- Why YARN
- In the TDP editions
Watch an application run
Press Play or step through one at a time. Underlined names lead to the Glossary.
1 The application is submitted
The client submits the application to the ResourceManager, along with the queue and priority in which it should run. The ApplicationsManager, one of the two parts of the ResourceManager, receives the submission.
In the Glossary: YARN Client · ApplicationsManager · Application · Queue
- The application is submitted. The client submits the application to the ResourceManager, along with the queue and priority in which it should run. The ApplicationsManager, one of the two parts of the ResourceManager, receives the submission.
- The first container belongs to the ApplicationMaster. The ApplicationsManager negotiates the application's first container, and the NodeManager on one of the machines starts it. The ApplicationMaster, the process that will drive this application, runs in it.
- The ApplicationMaster registers and requests containers. The ApplicationMaster registers with the ResourceManager and starts sending heartbeats, which show that it is alive. Based on what the tasks require, it asks the Scheduler for a set of containers, with the memory and vcores of each one.
- The Scheduler allocates. The Scheduler divides the resources among the running applications, respecting capacities and queues, and returns the allocated containers to the ApplicationMaster. It only allocates: it does not track the application's state.
- The NodeManagers start the containers. The ApplicationMaster asks the NodeManagers to start the containers, each with the command, environment and files the task needs. The NodeManager monitors the CPU, memory, disk and network usage of each container and reports to the ResourceManager.
- The ApplicationMaster tracks progress. The ApplicationMaster tracks the state of the containers and the progress of the work, and reports this progress to the ResourceManager on every heartbeat. The client queries the ResourceManager to learn the application's status.
- The application finishes. When the work is done, the ApplicationMaster unregisters from the ResourceManager and reports the final state, which the client receives in the application report. With log aggregation, the logs of each container are moved to a file system, such as HDFS.
Architecture
One ResourceManager for the cluster, one NodeManager per machine and one ApplicationMaster per application.
What the figure shows:
- The client submits the application to the ResourceManager. The one that receives the submission is the ApplicationsManager.
- The ApplicationsManager, one of the two parts of the ResourceManager, accepts submissions and starts each application's ApplicationMaster.
- The Scheduler, the other part of the ResourceManager, allocates the containers according to capacities and queues. The Capacity Scheduler divides the cluster into queues.
- The NodeManagers, one on each machine, start the containers, monitor the CPU, memory, disk and network usage of each one and report the node's state to the ResourceManager through heartbeats.
- The ApplicationMaster runs in the application's first container, requests resources from the Scheduler and tracks the state of the other containers.
- The containers each run a task of the application and report their state to the ApplicationMaster.
The ResourceManager and the NodeManagers form YARN's data-computation framework. The Scheduler's partitioning policy is pluggable.
From cluster to container
How the Capacity Scheduler divides the cluster: five levels, each inside the other.
Level 1 of 5
Cluster
The resources of all machines with a NodeManager. Each NodeManager declares the memory and vcores it can offer to containers, and the ResourceManager arbitrates these resources among all applications.
- NodeManagerThe agent on each machine: it starts and monitors the containers and reports to the ResourceManager.
- Cluster. The resources of all machines with a NodeManager. Each NodeManager declares the memory and vcores it can offer to containers, and the ResourceManager arbitrates these resources among all applications.
- NodeManager. The agent on each machine: it starts and monitors the containers and reports to the ResourceManager.
- Root queue. The root of the hierarchy: all queues in the system are its children, and its capacity is the cluster itself. If root is stopped, no application can be submitted to the cluster.
- Capacity Scheduler. The Scheduler policy that divides the cluster among organizations, with capacity guarantees.
- Queue. A guaranteed fraction of the cluster's capacity, given to an organization, which can be divided into subqueues. Free resources can go to a queue beyond its capacity, up to its maximum capacity. Each queue is identified by its path from root, with a dot as the separator.
- Queue ACLs. They define which users can submit applications to the queue and who can administer it.
- State. Running or stopped. In a stopped queue, existing applications run to completion, and no new ones are accepted.
- Application. A job or a DAG of jobs, submitted to a queue with a priority. Per-user limits within the queue prevent a single application, user or queue from monopolizing resources.
- ApplicationMaster. It runs in the application's first container and negotiates the others with the Scheduler.
- Container. The portion of a machine's resources in which a task runs, with the requested memory and vcores. The ResourceManager defines the minimum and maximum that each container request can receive.
- vcore. Virtual CPU unit that the Scheduler uses when allocating containers.
The Capacity Scheduler also performs preemption: it can reclaim containers from queues that are using more than their guaranteed capacity.
Queue definitions and properties such as capacity and ACLs can be changed while the cluster is running, and new queues can be added.
When something fails
Who notices each failure and what happens to the work in progress.
The NodeManager can terminate a container that uses more memory than it requested. The ApplicationMaster tracks the state of the application's containers. The Scheduler only allocates and does not restart tasks that fail, whether due to application failure or hardware failure.
The ApplicationsManager restarts the ApplicationMaster container, as a new attempt of the application, up to the configured maximum number of attempts.
The NodeManager checks the disks and, when configured, runs a node health script. If the check fails, it marks the node as unhealthy and notifies the ResourceManager, which stops allocating containers on that node.
With NodeManager recovery, set in yarn.nodemanager.recovery.enabled, it restarts without losing the active containers on the node.
The ResourceManager saves the state of the applications in a state store. When it comes back, it asks the NodeManagers and ApplicationMasters to re-sync. With work-preserving recovery, running applications continue, containers keep running, and the ApplicationMasters resend their pending requests.
With high availability, a standby ResourceManager takes over, as the next scene shows.
Two ResourceManagers, one active
What happens when the active ResourceManager goes offline.
1 One active, one on standby
At any moment, one ResourceManager is active and the others stay on standby, ready to take over. The active one saves the application state in ZooKeeper, in a store that accepts writes from only one ResourceManager at a time.
In the Glossary: ZooKeeper · ResourceManager · Clients · ApplicationMasters · NodeManagers · ResourceManager high availability
- One active, one on standby. At any moment, one ResourceManager is active and the others stay on standby, ready to take over. The active one saves the application state in ZooKeeper, in a store that accepts writes from only one ResourceManager at a time.
- The active one fails. The elector embedded in the ResourceManagers detects the failure and, together with ZooKeeper, decides which ResourceManager becomes the active one.
- The standby takes over. The new active one loads the saved state and continues from where the previous one left off, according to ResourceManager recovery.
- Everyone finds the new active one. Clients, ApplicationMasters and NodeManagers poll the configured ResourceManagers one after another until they reach the new active one. The NodeManagers keep their containers and report their state. The ApplicationMasters resend their pending requests.
Application history
Queue, user, attempts and containers of each completed application, and what each framework records.
The Timeline Service stores and returns application information: the generic information about each completed application, and the information specific to each framework. Version 2 distributes this work across three pieces.
Who writes
One collector per application
The collectors run inside the NodeManagers, as auxiliary services, one for each application. The ResourceManager maintains its own collector.
Where it is stored
In HBase
Apache HBase is the primary storage of version 2. Related applications are grouped into flows, and each execution of a flow is a flow run.
Who reads
Separate readers
The readers are separate processes from the collectors and serve queries about the history.
Logs follow their own path: with log aggregation, the logs of each container are moved to a file system, such as HDFS, after the application finishes.
Why YARN
Sharing
One cluster, many organizations
The Capacity Scheduler divides a large cluster among several organizations, with a capacity guarantee for each one.
Elasticity
Free capacity does not sit idle
Resources that one organization does not use can serve other queues beyond their capacity, up to each queue's maximum.
Limits
No one monopolizes the cluster
Per-application, per-user and per-queue limits prevent any one of them from taking the resources of the queue or the cluster.
Security
ACLs on every queue
Each queue has ACLs that define which users can submit applications to it.
Multiple engines
One arbiter for all frameworks
The ApplicationMaster is specific to each framework, and the ResourceManager arbitrates resources for all of them on the same cluster.
Operations
Queues adjusted while running
Capacities and ACLs change while the cluster is up, and a stopped queue lets running applications finish before it is drained.
Starting with Hadoop 2.x, MapReduce runs on YARN and maintains API compatibility with the previous stable release, Hadoop 1.x: MapReduce jobs continue to run on YARN with just a recompile.
In the TDP editions
| Edition | Version | Documentation |
|---|---|---|
| TDP Datacenter | 3.3.6 | TDP Datacenter components |
In TDP Datacenter
In TDP Datacenter, YARN is a stack service, installed and managed by Ambari.
APP_TIMELINE_SERVER (master, one instance), NODEMANAGER (slave, one or more), RESOURCEMANAGER (master, one or two), TIMELINE_READER (master, one or more), YARN_CLIENT (client, one or more) and YARN_REGISTRY_DNS (master, optional, one instance). The TIMELINE_READER requires HDFS_CLIENT (HDFS) and HBASE_CLIENT (HBase). Component category.
The Scheduler policy is set in yarn.resourcemanager.scheduler.class. The Capacity Scheduler queues are defined in the capacity-scheduler configuration, starting from yarn.scheduler.capacity.root.queues, with the capacity, maximum capacity, state and ACLs of each queue. See Queues and capacity in YARN.
Each NodeManager offers the memory and vcores set in yarn.nodemanager.resource.memory-mb and yarn.nodemanager.resource.cpu-vcores. The minimum and maximum per container are set in yarn.scheduler.minimum-allocation-mb, yarn.scheduler.maximum-allocation-mb and their vcore equivalents, and yarn.scheduler.capacity.resource-calculator defines whether the comparison uses only memory or CPU as well.
Resources beyond memory and vcores, such as GPU, can be enabled in yarn.resource-types and yarn.nodemanager.resource-plugins, with the GPU module in container-executor.
The runtimes allowed for the Linux container executor are configurable in yarn.nodemanager.runtime.linux.allowed-runtimes, and the Docker module can be enabled in container-executor.
Can be enabled in Ambari: the pair of ResourceManagers in yarn.resourcemanager.ha.enabled, with ZooKeeper in yarn.resourcemanager.zk-address; the state store in yarn.resourcemanager.store.class; recovery in yarn.resourcemanager.recovery.enabled, yarn.resourcemanager.work-preserving-recovery.enabled and yarn.nodemanager.recovery.enabled; the maximum number of attempts for each application, in yarn.resourcemanager.am.max-attempts. See ResourceManager high availability.
Can be enabled with the Scheduler monitors, in yarn.resourcemanager.scheduler.monitor.enable, and adjusted in the yarn.resourcemanager.monitor.capacity.preemption.* properties.
The active Timeline Service versions are set in yarn.timeline-service.versions. The Timeline Service V2.0 Reader depends on the HBase Client and the HDFS Client, with storage configurable in yarn-hbase-site. Log aggregation can be enabled in yarn.log-aggregation-enable, with the destination in yarn.nodemanager.remote-app-log-dir.
The Registry DNS can be enabled in hadoop.registry.dns.enabled, with the domain in hadoop.registry.dns.domain-name and the registration in ZooKeeper in hadoop.registry.zk.quorum.
These services require this one in the cluster: Flink, HDFS, Hive, JupyterLab, MapReduce, Spark, Tez and Zeppelin.
Spark, for example, runs its applications as YARN applications, with the queue in spark.yarn.queue. See Apache Spark.
YARN ACLs can be enabled in yarn.acl.enable, with the administrators in yarn.admin.acl. The Ranger plugin for YARN can be enabled in ranger-yarn-plugin-enabled. See Security in TDP Datacenter.
Next steps
TDP Datacenter
Data and processing on the same machines
YARN and HDFS in the cluster managed by Ambari.
TDP Datacenter
ResourceManager high availability
The pair of ResourceManagers and the recovery of running work.
Sources
Apache Hadoop YARN - Architecture
Apache Hadoop YARN - Writing YARN Applications
Apache Hadoop YARN - Capacity Scheduler
Apache Hadoop YARN - NodeManager
Apache Hadoop YARN - ResourceManager Restart
Apache Hadoop YARN - ResourceManager High Availability
Apache Hadoop YARN - Timeline Server
Apache Hadoop YARN - Timeline Service v.2