Skip to main content

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​

Press Play or step through one at a time. Underlined names lead to the Glossary.

ClientWho submits
YARN ClientSubmits the application to a queue
ResourceManagerWho arbitrates
ApplicationsManagerAccepts the submission
SchedulerAllocates containers by queue
Machine 1One NodeManager
NodeManagerStarts and monitors containers
ApplicationMasterIn the first container
ContainerRuns a task
Machine 2One NodeManager
NodeManagerStarts and monitors containers
ContainerRuns a task
ContainerRuns a task
Step 1 of 7

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.

  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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
Figure 1 - An application in YARN. The ResourceManager allocates the resources. The application's ApplicationMaster drives the work in the NodeManagers' containers.

Architecture​

One ResourceManager for the cluster, one NodeManager per machine and one ApplicationMaster per application.

YARN architecture: client, ResourceManager and NodeManagers with containersThe client submits the application to the ResourceManager, which has two parts: the ApplicationsManager, which accepts the submission and starts the ApplicationMaster, and the Scheduler, which allocates the containers. Each machine has a NodeManager, which starts and monitors the containers and reports the node state to the ResourceManager. The application's ApplicationMaster runs in a container, requests resources from the Scheduler and tracks the state of the application's other containers.ClientSubmits the applicationResourceManagerApplicationsManagerAccepts the submission andstarts the ApplicationMasterSchedulerAllocates containers per queueCapacity SchedulerNodeManagerContainerRuns a taskContainerRuns a taskNodeManagerApplicationMasterIn the first containerContainerRuns a taskNodeManagerContainerRuns a taskContainerRuns a taskApplication submissionNode state (heartbeat)Container request and allocationContainer state
Figure 2 - YARN architecture: the client, the ResourceManager with the ApplicationsManager and the Scheduler, and the NodeManagers with the containers, one of them with the ApplicationMaster. Underlined terms lead to the Glossary.

What the figure shows:

  1. The client submits the application to the ResourceManager. The one that receives the submission is the ApplicationsManager.
  2. The ApplicationsManager, one of the two parts of the ResourceManager, accepts submissions and starts each application's ApplicationMaster.
  3. The Scheduler, the other part of the ResourceManager, allocates the containers according to capacities and queues. The Capacity Scheduler divides the cluster into queues.
  4. 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.
  5. The ApplicationMaster runs in the application's first container, requests resources from the Scheduler and tracks the state of the other containers.
  6. 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.
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
Figure 3 - Each level contains the next: the cluster is divided into queues starting from the root queue, applications run in the queues, and each application runs in 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.

A container exceeds its memory

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 ApplicationMaster fails

The ApplicationsManager restarts the ApplicationMaster container, as a new attempt of the application, up to the configured maximum number of attempts.

A node becomes unhealthy

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.

The NodeManager restarts

With NodeManager recovery, set in yarn.nodemanager.recovery.enabled, it restarts without losing the active containers on the node.

The ResourceManager restarts

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.

The active ResourceManager goes down

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.

ZooKeeperElection and state
ZooKeeperElects the active one and stores the application state
ResourceManager 1Active at the start
ResourceManagerActive until it fails
ResourceManager 2On standby
ResourceManagerStandby, ready to take over
Who connectsTo the active ResourceManager
ClientsSubmit and query
ApplicationMastersRequest containers
NodeManagersReport the state of the nodes
Step 1 of 4

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.

  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.
  2. The active one fails. The elector embedded in the ResourceManagers detects the failure and, together with ZooKeeper, decides which ResourceManager becomes the active one.
  3. 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.
  4. 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.
Figure 4 - ResourceManager high availability. ZooKeeper decides which ResourceManager is active and stores the state of the applications. Whoever connects looks for the new active one.

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.

MapReduce on YARN

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​

Available in the TDP editions
EditionVersionDocumentation
TDP Datacenter3.3.6TDP Datacenter components

In TDP Datacenter​

In TDP Datacenter, YARN is a stack service, installed and managed by Ambari.

Service components

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.

Scheduler and queues

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.

Node and container resources

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.

Other resource types

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.

Container runtimes

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.

High availability and recovery

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.

Preemption

Can be enabled with the Scheduler monitors, in yarn.resourcemanager.scheduler.monitor.enable, and adjusted in the yarn.resourcemanager.monitor.capacity.preemption.* properties.

History and logs

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.

Service discovery

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.

Dependencies

Ambari requires in the cluster HDFS, MapReduce and ZooKeeper.

Required by

These services require this one in the cluster: Flink, HDFS, Hive, JupyterLab, MapReduce, Spark, Tez and Zeppelin.

What depends on YARN

Spark, for example, runs its applications as YARN applications, with the queue in spark.yarn.queue. See Apache Spark.

Authorization

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​

Sources​

Apache Hadoop

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

Apache Hadoop YARN - Service Discovery

Apache Hadoop YARN - yarn-default.xml