efficient cluster resource management by using cook and mesos / li jin (two sigma)

67
Efficient cluster resource management using Mesos and Cook Li Jin

Upload: ontico

Post on 06-Jan-2017

605 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Efficient cluster resource management using Mesos and CookLi Jin

Page 2: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

About Me• Software Engineer @ Two Sigma

Page 3: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Outline• Introduction: Mesos and Cook

Page 4: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Mesos• Open Source Apache Project• 2010: AMPLab, University of California Berkeley

• 2012: Twitter, Airbnb• 2015: Twitter, Airbnb, Apple, Bloomberg, Cisco,

eBay, Yelp…

Page 5: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Mesos• Tool to build distributed applications

– Hadoop, Spark…– Cassandra, Kafta, Riak…

Page 6: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Mesos• Distributed applications commonality:

– Manages resources (cpu, memory, disk…) on worker hosts

– Manages life cycle of remote processes– Manages communication between masters

and workers

Page 7: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Mesos

Page 8: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Mesos

Page 9: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Mesos

Page 10: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Mesos• Distributed applications commonality:

– Manages resources (cpu, memory, disk…) on worker hosts

– Manages life cycle of remote processes– Manages communication between masters

and workers

Page 11: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Mesos Primitives

Page 12: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Mesos @ Two Sigma

Cook

Mesos

Page 13: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Cook• Two Sigma’s Simulation Platform

• Manages tens of thousands of simulations • Shares compute resources among users

Page 14: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Simulation• Idempotent, distributed, resource intensive

computations• Simulation set• A handful ~ thousands of simulations

• Simulation• Multiple Mesos tasks

Page 15: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Simulation• Simulation task footprint• 10 ~ 100 GB RAM• 1 ~ 20 CPUs• 15 minutes ~ a few hours

• Simulation use cases• Interactive• Batch processing

Page 16: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Problem• High resource demand• 5 x capacity during peak hours

• Optimize• Utilization• Process workloads as fast as possible

• Fairness• Allocate resources fairly to users

Page 17: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Fairness• FIFO• Time sharing• Throw a dice• …

Page 18: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Fairness• A story…

Page 19: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is FairnessResource Allocation

Page 20: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

What is Fairness, Really• Fairness is not about ‘fair’• Fairness is about user experience

• User should get their share of the cluster whenever they need it

Page 21: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Outline• Introduction: Mesos and Cook• Problem: Utilization and Fairness• Fairness: How do we do it

Page 22: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Static Quota• Quota = Max percentage of the cluster allowed for

single user• Static

• 100 % / # Max concurrent users• Pros:

• Fairness• Cons:

• Poor Utilization

Page 23: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Dynamic Quota• Dynamic

• Quota * Utilization Adjustment• Pros:

• Higher Utilization• Cons:

• Poor Fairness

Page 24: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Dynamic Quota

Unfair Resource Allocation

Fair Resource Al-location

Hours…

Page 25: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Can we do better?

Static Quota Dynamic Quota ?

FairnessUtilization

Page 26: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption• Kill a Simulation task and reschedule later• Reclaim resource faster!

Unfair Resource Allocation

Minutes!

Fair Resource Al-location

Page 27: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Outline• Introduction: Mesos and Cook• Problem: Utilization and Fairness• Fairness: How do we do it• Preemption: How do we do it

Page 28: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

Running

Waiting

Page 29: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

Running

Waiting

Page 30: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

Running

Waiting

Page 31: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

??

?

??

?Running

Waiting

Page 32: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

Running

Waiting

Page 33: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

Running

Waiting

Page 34: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

Running

Waiting

Page 35: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

Running

Waiting

Page 36: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

Running

Waiting

Page 37: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

Running

Waiting

Page 38: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Problem• Not all tasks are equal

• We just preempted some important tasks!

Bad User Experience

Page 39: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Score Function• Score Function: Reflect task’s value

• Fairness• Importance

• Preemption principal:• Preempt low score task for high score task

Page 40: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

€€€€€€

Running

Waiting

££££££££££££

¥¥¥¥¥¥¥¥¥

Page 41: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

₽₽₽₽₽₽

Running

Waiting

₽₽₽₽₽₽

₽₽₽₽₽₽

Page 42: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

₽₽₽₽₽₽

Running

Waiting

₽₽₽₽₽₽

₽₽₽₽₽₽

Page 43: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

₽₽₽₽₽₽

Running

Waiting

₽₽₽₽₽₽

₽₽₽₽₽₽

Page 44: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

₽₽₽₽₽

Running

Waiting

₽₽₽₽₽₽

₽₽₽

₽₽₽

Page 45: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

₽₽₽₽₽

Running

Waiting

₽₽₽₽₽₽

₽₽₽

₽₽₽

Page 46: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

₽₽₽₽₽

Running

Waiting

₽₽₽₽₽

₽₽₽₽₽

Page 47: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Intuition

€€€€€

Running

Waiting

£££££££££

£££

¥¥¥¥¥¥¥

¥¥

Page 48: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Outline• Introduction: Mesos and Cook• Problem: Utilization and Fairness• Fairness: How do we do it• Preemption: How do we do it

• Intuition• Formalization

Page 49: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Cumulative Resource Share (CRS)

• Assuming there is an total order of tasks for each user, where > means ‘more important than’. – CRS of task t is sum of all tasks of the same user

that are greater than or equal to t, divided by total cluster resource.

Page 50: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Cumulative Resource Share (CRS)• ,

Page 51: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Formalization

€€€€€€

Running

Waiting

££££££££££££

¥¥¥¥¥¥¥¥¥

Page 52: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Formalization

1/62/63/6

Running

Waiting

1/62/63/6

1/62/63/6

Page 53: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Formalization

1/62/63/6

Running

Waiting

1/62/63/6

1/62/63/6

Page 54: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Formalization

1/62/6

3/6

Running

Waiting

1/62/63/6

1/6

2/63/6

Page 55: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Preemption: Formalization

1/62/6

3/6

Running

Waiting

1/62/6

3/6

1/62/6

3/6

Page 56: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Multiple Resources?• Dominant Resource Fairness: Fair Allocation of

Multiple Resource Types • Published by UC Berkeley in 2011

Page 57: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Dominant Cumulative Resource Share

Page 58: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Outline• Introduction: Mesos and Cook• Problem: Utilization and Fairness• Fairness: How do we do it• Preemption: How do we do it

• Intuition• Formalization

• Put things together: Mesos and Cook

Page 59: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Cook: Architecture

Page 60: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Are we doing better?

Static Quota Dynamic Quota Preemption?

FairnessUtilization

Page 61: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Outline• Introduction: Mesos and Cook• Problem: Utilization and Fairness• Fairness: How do we do it• Preemption: How do we do it

• Intuition• Formalization

• Put things together: Mesos and Cook• Benchmark

Page 62: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Benchmark• Simulated• 7 day production workload trace

Page 63: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Benchmark

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

2

4

6

8

10

12

Simulation Set Speed Up Distribution

Dynamic QuotaPreemption

Spee

d U

p

Page 64: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Benchmark

Day 1 Day 2 Day 3 Day 4 Day 5 Day 6 Day 70

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

Effective Utilization

Dynamic QuotaPreemption

Util

izati

on

Page 65: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

It works!

Page 66: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Open Source• https://github.com/apache/mesos• https://github.com/twosigma/cook

• @icexelloss

Page 67: Efficient cluster resource management by using Cook and Mesos / Li Jin (Two Sigma)

Questions?