Hadoop was originally designed for running large batch jobs, but users wanted to share clusters for better utilization and lower costs. Sharing requires a scheduler that provides guaranteed capacity for production jobs while also giving interactive jobs good response times. The Fair Scheduler was developed to address this by assigning jobs to pools that each get a minimum share of resources, with excess allocated fairly between pools. However, strictly following queues can hurt data locality. Delay Scheduling improves locality by relaxing the queues for a short time to allow more data-local scheduling opportunities.
2. Hadoopas batch processing system
•Hadoopwas designed mainly for running large batch jobs such as web indexing and log mining.
•Users submitted jobs to a queue, and the cluster ran them in order.
•Soon, another use case became attractive:
–Sharing a MapReducecluster between multiple users.
3. The benefits of sharing
•With all the data in one place, users can run queries that they may never have been able to execute otherwise, and
•Costs go down because system utilization is higher than building a separate Hadoopcluster for each group.
•However, sharing requires support from the Hadoopjob scheduler to
–provide guaranteed capacity to production jobs and
–good response time to interactive jobs while allocating resources fairly between users.
4. Approaches to Sharing
•FIFO : In FIFO scheduling, a JobTrackerpulls jobs from a work queue, oldest job first. This schedule had no concept of the priority or size of the job
•Fair : Assign resources to jobs such that on average over time, each job gets an equal share of the available resources. The result is that jobs that require less time are able to access the CPU and finish intermixed with the execution of jobs that require more time to execute. This behavior allows for some interactivity among Hadoopjobs and permits greater responsiveness of the Hadoopcluster to the variety of job types submitted.
•Capacity : In capacity scheduling, instead of pools, several queues are created, each with a configurable number of map and reduce slots. Each queue is also assigned a guaranteed capacity (where the overall capacity of the cluster is the sum of each queue's capacity). Queues are monitored; if a queue is not consuming its allocated capacity, this excess capacity can be temporarily allocated to other queues.
11. Fair Scheduler Basics
•Group jobs into “pools”
•Assign each pool a guaranteed minimum share
•Divide excess capacity evenly between pools
12. Pools
•Determined from a configurable job property
–Default in 0.20: user.name (one pool per user)
•Pools have properties:
–Minimum map slots
–Minimum reduce slots
–Limit on # of running jobs
13. Example Pool Allocations
entire cluster100 slots
emp1
emp2
finance
min share = 40
emp6
min share = 30
job 2
15 slots
job 3
15 slots
job 1
30 slots
job 4
40 slots
14. Scheduling Algorithm
•Split each pool’s min share among its jobs
•Split each pool’s total share among its jobs
•When a slot needs to be assigned:
–If there is any job below its min share, schedule it
–Else schedule the job that we’ve been most unfair to (based on “deficit”)
17. Additional Features
•Weights for unequal sharing:
–Job weights based on priority (each level = 2x)
–Job weights based on size
–Pool weights
•Limits for # of running jobs:
–Per user
–Per pool
18. Installing the Fair Scheduler
•Build it:
–ant package
•Place it on the classpath:
–cp build/contrib/fairscheduler/*.jar lib
19. Configuration Files
•Hadoop config(conf/mapred-site.xml)
–Contains scheduler options, pointer to pools file
•Pools file (pools.xml)
–Contains min share allocations and limits on pools
–Reloaded every 15 seconds at runtime
26. Other Parameters
mapred.fairscheduler.poolnameproperty:
•Which JobConfproperty sets what pool a job is in
-Default: user.name (one pool per user)
-Can make up your own, e.g. “pool.name”, and pass in JobConfwith conf.set(“pool.name”, “mypool”)
27. Useful Setting
<property>
<name>mapred.fairscheduler.poolnameproperty</name>
<value>pool.name</value>
</property>
<property>
<name>pool.name</name>
<value>${user.name}</value>
</property>
Make pool.name default to user.name
28. Issues with Fair Scheduler
–Fine-grained sharing at level of map & reduce tasks
–Predictable response times and user isolation
•Problem:data locality
–For efficiency, must run tasks near their input data
–Strictly following any job queuing policy hurts locality: job picked by policy may not have data on free nodes
•Solution:delay scheduling
–Relax queuing policy for limited time to achieve locality
30. The Problem
Job 1
Master
Job 2
Scheduling order
Slave
Slave
Slave
Slave
Slave
Slave
4
2
1
2
2
3
9
5
3
3
6
7
5
6
9
4
8
7
8
2
1
1
Task 2
Task 5
3
Task 1
File 1:
File 2:
Task 1
7
Task 2
Task 4
3
Problem: Fair decision hurts locality
Especially bad for jobs with small input files
1
3
31. Solution: Delay Scheduling
•Relax queuing policy to make jobs wait for a limited time if they cannot launch local tasks
•Result: Very short wait time (1-5s) is enough to get nearly 100% locality
33. Delay Scheduling Details
•Scan jobs in order given by queuing policy, picking first that is permitted to launch a task
•Jobs must wait before being permitted to launch non-local tasks
–If wait < T1, only allow node-local tasks
–If T1< wait < T2, also allow rack-local
–If wait > T2, also allow off-rack
•Increase a job’s time waited when it is skipped
34. Capacity Scheduler
•Organizes jobs into queues
•Queue shares as %’s of cluster
•FIFO scheduling within each queue
•Supports preemption
•Queues are monitored; if a queue is not consuming its allocated capacity, this excess capacity can be temporarily allocated to other queues.