The fair scheduler is a scheduler plugin that fairly distributes an equal share of resources for jobs in the YARN cluster.
When there is a single app running, that app uses the entire cluster. When other apps are submitted, resources that free up are assigned to the new apps following the following rule:
Each apps app gets roughly the same amount of resources over time (known as equal share).
Unlike the default Hadoop scheduler, which forms a real queue of apps, this lets short apps finish in reasonable time while not starving long-lived apps.
Queue is the unit of resource fairness. They are used to;
By default, all users share a single queue, named default.
If an app specifically lists a queue in a container resource request, the request is submitted to that queue.
Queues are assigned:
based on the policy
Queues can be arranged in a hierarchy to divide resources and configured with weights to share the cluster in specific proportions.
All queues descend from a queue named root. Available resources are distributed from the root queue recursively among the children. Applications may only be scheduled on leaf queues.
Queues can be specified as children of other queues by placing them as sub-elements of their parents in the fair scheduler allocation file.
A queue’s name starts with the names of its parents, with periods as separators.
[root].parent.....children
where the root part of the name is optional.
Example:
Minimum Share.
The Fair Scheduler allows assigning minimum shares to queues (also known as guaranteed share). This is useful for ensuring that production applications always get sufficient resources.
When a queue contains apps, it gets at least its minimum share, but when the queue does not need it, the excess is split between other running apps.
The Max number of running app.
The Fair Scheduler lets all apps run by default, but it is also possible to limit the number of running apps per user and per queue.
Limited apps will wait in the scheduler’s queue until the actual running apps finish.
Within each queue, a scheduling policy is used to share resources between the running apps.
The Fair Scheduler bases scheduling fairness decisions can be:
Policies extends org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.SchedulingPolicy. Built-in:
A policy consists of a set of rules that are applied sequentially to classify an incoming application. Each rule either places the app into a queue, rejects it, or continues on to the next rule.
app priorities are used as weights to determine the fraction of total resources that each app should get.
in the conf file
<property>
<name>yarn.resourcemanager.scheduler.class</name>
<value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>
</property>
Two files for two scope:
The reservation system in the context of the fair scheduler.
It's not enabled by default. The application can request reserved resources at runtime by specifying the reservationId during submission.
See:
yarnUi/cluster/scheduler
Fair Scheduler is able to dump its state periodically. It is disabled by default. The administrator can enable it by setting org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler.statedump logging level to DEBUG.
Fair Scheduler state dumps can potentially generate a large amount of log data.
Fair Scheduler logs go to the Resource Manager log file by default. Uncomment the “Fair scheduler state dump” section in log4j.properties to dump the state into a separate file.