0% found this document useful (0 votes)
79 views7 pages

YARN Scheduler Overview and Configuration

The document discusses different scheduling options in YARN including FIFO, Capacity, and Fair Schedulers. It describes how each scheduler allocates resources and provides an example configuration of the Capacity Scheduler.

Uploaded by

Varshini
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views7 pages

YARN Scheduler Overview and Configuration

The document discusses different scheduling options in YARN including FIFO, Capacity, and Fair Schedulers. It describes how each scheduler allocates resources and provides an example configuration of the Capacity Scheduler.

Uploaded by

Varshini
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Scheduling in YARN

In an ideal world, the requests that a YARN application makes would be


granted immediately. In the real world, however, resources are limited, and on a
busy cluster, an application will often need to wait to have some of its requests
fulfilled. It is the job of the YARN scheduler to allocate resources to
applications according to some defined policy. Scheduling in general is a
difficult problem and there is no one “best” policy, which is why YARN
provides a choice of schedulers and configurable policies. We look at these
next.

Scheduler Options

Three schedulers are available in YARN: the FIFO, Capacity, and Fair
Schedulers. The FIFO Scheduler places applications in a queue and runs them
in the order of submission (first in, first out). Requests for the first application in
the queue are allocated first; once its requests have been satisfied, the next
application in the queue is served, and so on.

The FIFO Scheduler has the merit of being simple to understand and not
needing any configuration, but it’s not suitable for shared clusters. Large
applications will use all the resources in a cluster, so each application has to
wait its turn. On a shared cluster it is better to use the Capacity Scheduler or the
Fair Scheduler. Both of these allow long-running jobs to complete in a timely
manner, while still allowing users who are running concurrent smaller ad hoc
queries to get results back in a reasonable time.

The difference between schedulers is illustrated in Figure , which shows that


under the FIFO Scheduler (i) the small job is blocked until the large job
completes.
With the Capacity Scheduler (ii in Figure ), a separate dedicated queue allows
the small job to start as soon as it is submitted, although this is at the cost of
overall cluster utilization since the queue capacity is reserved for jobs in that
queue. This means that the large job finishes later than when using the FIFO
Scheduler.
With the Fair Scheduler (iii in Figure ), there is no need to reserve a set
amount of capacity, since it will dynamically balance resources between all
running jobs. Just after the first (large) job starts, it is the only job running, so it
gets all the resources in the cluster. When the second (small) job starts, it is
allocated half of the cluster resources so that each job is using its fair share of
resources.

Note that there is a lag between the time the second job starts and when it
receives its fair share, since it has to wait for resources to free up as containers
used by the first job complete. After the small job completes and no longer
requires resources, the large job goes back to using the full cluster capacity
again. The overall effect is both high cluster utilization and timely small job
completion.

Figure 1. Cluster utilization over time when running a large job and a small
job under the FIFO Scheduler (i), Capacity Scheduler (ii), and Fair Scheduler
(iii)

Capacity Scheduler Configuration


The Capacity Scheduler allows sharing of a Hadoop cluster along organizational
lines, whereby each organization is allocated a certain capacity of the overall
cluster. Each organization is set up with a dedicated queue that is configured to
use a given fraction of the cluster capacity. Queues may be further divided in
hierarchical fashion, allowing each organization to share its cluster allowance
between different groups of users within the organization. Within a queue,
applications are scheduled using FIFO scheduling.

a single job does not use more resources than its queue’s capacity. However, if
there is more than one job in the queue and there are idle resources available,
then the Capacity Scheduler may allocate the spare resources to jobs in the
queue, even if that causes the queue’s capacity to be exceeded. This behavior is
known as queue elasticity.
In normal operation, the Capacity Scheduler does not preempt containers by
forcibly killing them, so if a queue is under capacity due to lack of demand, and
then demand increases, the queue will only return to capacity as resources are
released from other queues as containers complete. It is possible to mitigate this
by configuring queues with a maximum capacity so that they don’t eat into
other queues’ capacities too much. This is at the cost of queue elasticity, of
course, so a reasonable trade-off should be found by trial and error.

Imagine a queue hierarchy that looks like this:

root

├── prod

└── dev

├── eng

└── science

The Example shows a sample Capacity Scheduler configuration file,


called [Link], for this hierarchy. It defines two queues under
the root queue, prod and dev, which have 40% and 60% of the capacity,
respectively. Notice that a particular queue is configured by setting
configuration properties of the form [Link].<queue-
path>.<sub-property>, where <queue-path> is the hierarchical (dotted) path of
the queue, such as [Link].
Example 4-1. A basic configuration file for the Capacity Scheduler

<?xml version="1.0"?>
<configuration>
<property>
<name>[Link]</name>
<value>prod,dev</value>
</property>
<property>
<name>[Link]</name>
<value>eng,science</value>
</property>
<property>
<name>[Link]</name>
<value>40</value>
</property>
<property>
<name>[Link]</name>
<value>60</value>
</property>
<property>
<name>[Link]-capacity</name>
<value>75</value>
</property>
<property>
<name>[Link]</name>
<value>50</value>
</property>
<property>
<name>[Link]</name>
<value>50</value>
</property>
</configuration>

the dev queue is further divided into eng and science queues of equal capacity.
So that the dev queue does not use up all the cluster resources when
the prod queue is idle, it has its maximum capacity set to 75%. In other words,
the prod queue always has 25% of the cluster available for immediate use. Since
no maximum capacities have been set for other queues, it’s possible for jobs in
the eng or science queues to use all of the dev queue’s capacity (up to 75% of
the cluster), or indeed for the prod queue to use the entire cluster.
Beyond configuring queue hierarchies and capacities, there are settings to
control the maximum number of resources a single user or application can be
allocated, how many applications can be running at any one time, and ACLs on
queues. See the reference page for details.

Queue placement
The way that you specify which queue an application is placed in is specific to
the application. For example, in MapReduce, you set the
property [Link] to the name of the queue you want to use. If
the queue does not exist, then you’ll get an error at submission time. If no queue
is specified, applications will be placed in a queue called default.

Preemption
When a job is submitted to an empty queue on a busy cluster, the job cannot
start until resources free up from jobs that are already running on the cluster. To
make the time taken for a job to start more predictable, the Fair Scheduler
supports pre-emption
Preemption allows the scheduler to kill containers for queues that are running
with more than their fair share of resources so that the resources can be
allocated to a queue that is under its fair share. preemption reduces overall
cluster efficiency, since the terminated containers need to be reexecuted.
Preemption is enabled globally by setting [Link] to true.
There are two relevant preemption timeout settings: one for minimum share and
one for fair share, both specified in seconds.
By default, the timeouts are not set, so you need to set at least one to allow
containers to be preempted. If a queue waits for as long as its minimum share
preemption timeout without receiving its minimum guaranteed share, then the
scheduler may preempt other containers.
The default timeout is set for all queues via the default MinShare Preemption
Timeout toplevel element in the allocation file, and on a per-queue basis by
setting the minShare Preemption Timeout element for a queue. Likewise, if a
queue remains below half of its fair share for as long as the fair share
preemption timeout, then the scheduler may preempt other containers. The
default timeout is set for all queues via the default FairShare Preemption
Timeout top-level element in the allocation file, and on a per-queue basis by
setting fair Share Preemption Timeout on a queue. The threshold may also be
changed from its default of 0.5 by setting default FairShare Preemption
Threshold and fairSharePreemptionThres hold (per-queue).

Delay Scheduling All the YARN schedulers try to honor locality requests. On a
busy cluster, if an appli‐ cation requests a particular node, there is a good chance
that other containers are run‐ ning on it at the time of the request. The obvious
course of action is to immediately loosen the locality requirement and allocate a
container on the same rack. However, it has been observed in practice that
waiting a short time (no more than a few seconds) can dramatically increase the
chances of being allocated a container on the requested node, and therefore
increase the efficiency of the cluster. This feature is called delay scheduling,
and it is supported by both the Capacity Scheduler and the Fair Scheduler.
Every node manager in a YARN cluster periodically sends a heartbeat request to
the resource manager—by default, one per second. Heartbeats carry information
about the node manager’s running containers and the resources available for
new containers, so each heartbeat is a potential scheduling opportunity for an
application to run a container. When using delay scheduling, the scheduler
doesn’t simply use the first scheduling opportunity it receives, but waits for up
to a given maximum number of scheduling opportunities to occur before
loosening the locality constraint and taking the next scheduling opportunity.

Dominant Resource Fairness:


For the Capacity Scheduler, delay scheduling is configured by setting
[Link]-locality-delay to a positive integer representing the
number of scheduling opportunities that it is prepared to miss before loosening
the node constraint to match any node in the same rack. The Fair Scheduler also
uses the number of scheduling opportunities to determine the delay, although it
is expressed as a proportion of the cluster size. For example, setting
[Link] to 0.5 means that the scheduler
should wait until half of the nodes in the cluster have presented scheduling
opportunities before accepting another node in the same rack. There is a
corresponding property, [Link], for setting
the threshold before another rack is accepted instead of the one requested.
Dominant Resource Fairness When there is only a single resource type being
scheduled, such as memory, then the concept of capacity or fairness is easy to
determine. If two users are running applications, you can measure the amount of
memory that each is using to compare the two applications. However, when
there are multiple resource types in play, things get more com ‐ plicated. If one
user’s application requires lots of CPU but little memory and the other’s
requires little CPU and lots of memory, how are these two applications
compared? The way that the schedulers in YARN address this problem is to
look at each user’s dominant resource and use it as a measure of the cluster
usage. This approach is called Dominant Resource Fairness, or DRF for short.9
The idea is best illustrated with a simple example. Imagine a cluster with a total
of 100 CPUs and 10 TB of memory. Application A requests containers of (2
CPUs, 300 GB), and application B requests containers of (6 CPUs, 100 GB). A’s
request is (2%, 3%) of the cluster, so memory is dominant since its proportion
(3%) is larger than CPU’s (2%). B’s request is (6%, 1%), so CPU is dominant.
Since B’s container requests are twice as big in the dominant resource (6%
versus 3%), it will be allocated half as many containers under fair sharing. By
default DRF is not used, so during resource calculations, only memory is
considered and CPU is ignored. The Capacity Scheduler can be configured to
use DRF by setting [Link]-calculator to
[Link] .[Link] in capacity-
[Link]. For the Fair Scheduler, DRF can be enabled by setting the top-
level element default QueueSchedulingPolicy in the allocation file to drf.

Common questions

Powered by AI

The FIFO Scheduler processes applications in the order of submission, meaning a small job must wait for a large job to complete, leading to potential delays for smaller tasks . The Capacity Scheduler improves on this by allowing separate queues which allocate specific fractions of the cluster's capacity to each job type, running small jobs immediately while potentially delaying larger jobs to ensure timely small job completion . The Fair Scheduler dynamically assigns available resources so each job gets a fair share of resources; smaller jobs can start even if a large job is running, enhancing resource utilization while providing timely execution of small jobs as cluster resources are balanced dynamically .

In the Fair Scheduler, preemption allows resources from jobs exceeding their fair share to be reallocated to under-resourced queues, improving fairness but potentially reducing overall efficiency since preempted containers need to be re-executed . Delay scheduling enhances node-local resource allocation by waiting for a specified number of scheduling opportunities before relaxing locality constraints, thus improving efficiency by allowing containers to run where they can optimally utilize resources .

Dominant Resource Fairness (DRF) in YARN manages multiple resource types by allocating resources based on the dominant resource requirement of an application. If two applications require different resource proportions (e.g., more CPU vs. more memory), DRF uses the larger of the two percentages as the dominant resource to determine capacity allocation. DRF aims to ensure equitable resource sharing by balancing the dominant resource usage across different applications, which effectively supports various resource-intensive tasks concurrently . DRF is enabled in the Capacity Scheduler by setting specific resource calculator configurations, and in the Fair Scheduler by adjusting queue scheduling policies .

YARN employs a combination of scheduling policies like the Fair Scheduler, which dynamically adjusts resource allocations so that each job receives its fair share as resources become available. This strategy allows large jobs to utilize full cluster capacity when alone, but adjusts as smaller jobs are submitted by re-balancing available resources, ensuring small jobs can complete in a timely manner without excessive delay, hence maintaining high cluster utilization .

Applications in YARN are assigned to queues based on explicit configuration properties, such as setting mapreduce.job.queuename for MapReduce jobs. If a specified queue does not exist, an error occurs during job submission. If no queue is specified, applications default to a queue named 'default.' This defaulting can lead to resource contention and inefficiencies if too many applications are sent to the default queue without consideration .

The Capacity Scheduler manages resource allocation in a YARN cluster through a hierarchical queue system, allocating specific fractions of the cluster's capacity to each queue. Queue elasticity allows for allocation of excess resources to jobs within a queue if available, though this can exceed the queue's intended capacity . Additionally, the Capacity Scheduler avoids preempting containers to maintain resource utilization efficiency, instead adjusting to resource demands as they change .

To enable Dominant Resource Fairness (DRF) in YARN using the Capacity Scheduler, you configure the property yarn.scheduler.capacity.resource-calculator to org.apache.hadoop.yarn.util.resource.DominantResourceCalculator in the capacity-scheduler.xml file . For the Fair Scheduler, DRF is enabled by setting the default QueueSchedulingPolicy in the allocation file to 'drf'. This setup ensures resources are allocated based on dominant resource demands, facilitating balanced resource distribution across different applications .

Delay scheduling can significantly improve job execution efficiency by waiting for optimal scheduling opportunities that meet locality requests. In the Capacity Scheduler, delay scheduling is configured by setting yarn.scheduler.capacity.node-locality-delay, which determines how many scheduling opportunities to skip before changing node constraints . In the Fair Scheduler, delay is configured through properties like yarn.scheduler.fair.locality.threshold.node as a proportion of available cluster nodes, allowing flexibility in resource allocation while honoring locality, thus enhancing efficiency .

Configuring a Capacity Scheduler involves balancing queue capacity and elasticity. Setting a maximum capacity for queues can prevent over-utilization but also limits queue elasticity, requiring a trade-off between predictability and flexibility . Furthermore, while it facilitates efficient resource allocation by hierarchically dividing resources among multiple queues, configuring the appropriate capacity for each requires careful consideration, as misconfigurations can lead to under-utilization or inefficient resource allocation .

The Fair Scheduler's preemption feature can reduce overall cluster efficiency by forcibly terminating containers, which then require restarting. This feature is controlled through preemption timeouts for minimum and fair shares, allowing resource redistribution when queues remain under-allocated beyond set thresholds . To enable preemption, set yarn.scheduler.fair.preemption to true, with necessary timeout configurations for accurate preemption triggers .

You might also like