Top Banner
Heterogeneous Resource Scheduling Using Apache Mesos for Cloud Native Frameworks Sharma Podila Senior Software Engineer Netflix June 2015
62

Resource Scheduling using Apache Mesos in Cloud Native Environments

Jul 28, 2015

Download

Software

Sharma Podila
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Resource Scheduling using Apache Mesos in Cloud Native Environments

Heterogeneous Resource Scheduling Using Apache Mesos for Cloud Native Frameworks

Sharma PodilaSenior Software Engineer

Netflix

June 2015

Page 2: Resource Scheduling using Apache Mesos in Cloud Native Environments

Scale to Internet traffic

Page 3: Resource Scheduling using Apache Mesos in Cloud Native Environments

Scale to Internet traffic

… embrace failure

Page 4: Resource Scheduling using Apache Mesos in Cloud Native Environments

Context

● Operational intelligence, Edge Engineering

Page 5: Resource Scheduling using Apache Mesos in Cloud Native Environments

Context

● Operational intelligence, Edge Engineering● Near real time detection of anomalies from

customers' streaming experience

Page 6: Resource Scheduling using Apache Mesos in Cloud Native Environments

Context

● Operational intelligence, Edge Engineering● Near real time detection of anomalies from

customers' streaming experience● Stream processing platform to run ad hoc

queries on live event streams

Page 7: Resource Scheduling using Apache Mesos in Cloud Native Environments

Context

● Operational intelligence, Edge Engineering● Near real time detection of anomalies from

customers' streaming experience● Stream processing platform to run ad hoc

queries on live event streams● Iterative detection of coarse grain and fine

grain signals

Page 8: Resource Scheduling using Apache Mesos in Cloud Native Environments

Efficient platform

Page 9: Resource Scheduling using Apache Mesos in Cloud Native Environments

Efficient platform

● do it cheap

Page 10: Resource Scheduling using Apache Mesos in Cloud Native Environments

Efficient platform

● do it cheap● do it quick

Page 11: Resource Scheduling using Apache Mesos in Cloud Native Environments

Efficient platform

● do it cheap● do it quick● scale with Netflix traffic

Page 12: Resource Scheduling using Apache Mesos in Cloud Native Environments

Mantis: reactive stream processing

● Cloud native

Page 13: Resource Scheduling using Apache Mesos in Cloud Native Environments

Mantis: reactive stream processing

● Cloud native● Lightweight jobs

Page 14: Resource Scheduling using Apache Mesos in Cloud Native Environments

Mantis: reactive stream processing

● Cloud native● Lightweight jobs● Dynamic jobs

Page 15: Resource Scheduling using Apache Mesos in Cloud Native Environments

Mantis: reactive stream processing

● Cloud native● Lightweight jobs● Dynamic jobs● Custom SLAs

Page 16: Resource Scheduling using Apache Mesos in Cloud Native Environments

Bi-directional data sourcingS

ourc

e ap

p in

stan

ces

01

2

999

0

1

23

45

Source connectorjob

Subscribe with query

Data pushed with subscription ID

UserJob 1

UserJob 2

UserJob 3

Subsc

riptio

n

Dis

cove

ry

Page 17: Resource Scheduling using Apache Mesos in Cloud Native Environments

Mantis system overview

MantisMantis

Apache MesosApache Mesos

Mantis

Apache Mesos

ASGASG

ASGFenzo

MesosFramework

ZooKeeper

Inst

ance

Apache MesosSlave Cluster

Page 18: Resource Scheduling using Apache Mesos in Cloud Native Environments

Mantis scheduling model

JobJobJob

SourceStage1Stage2Sink

Jobs may be perpetual oron-demand/interactive

Slave instances

Page 19: Resource Scheduling using Apache Mesos in Cloud Native Environments

Apache Mesos

Page 20: Resource Scheduling using Apache Mesos in Cloud Native Environments

Apache Mesos Architecture

Mesos slave

FrmWrk2 executor

TaskTask

Mesos slave

FrmWrk2 executor

FrmWrk1 executor

TaskTask

Mesos master Standby master Standby master

Mesos slave

FrmWrk1 executor

TaskTask

FrmWrk1 FrmWrk2ZooKeeper

quorum

Page 21: Resource Scheduling using Apache Mesos in Cloud Native Environments

Why Apache Mesos in a Cloud?

Page 22: Resource Scheduling using Apache Mesos in Cloud Native Environments

Resource granularity

Instance 1Instance 1

Task A

Instance 2

Task B

Instance 1

Task A

Instance 1

Task A

Task B

Task C Task Dvs.

Page 23: Resource Scheduling using Apache Mesos in Cloud Native Environments

Task start latency

vs.

Instance startup in mins. Mesos task startup in <1sec

Page 24: Resource Scheduling using Apache Mesos in Cloud Native Environments

Do we need yet another Mesos framework?

Page 25: Resource Scheduling using Apache Mesos in Cloud Native Environments

A choice of Mesos frameworks exists in the community

Page 26: Resource Scheduling using Apache Mesos in Cloud Native Environments

Likely easy to write a new framework

Page 27: Resource Scheduling using Apache Mesos in Cloud Native Environments

Likely easy to write a new frameworkWhat about scale, performance, fault tolerance, and availability?

Page 28: Resource Scheduling using Apache Mesos in Cloud Native Environments

Likely easy to write a new frameworkWhat about scale, performance, fault tolerance, and availability?

Scheduling is a hard problem to solve

Page 29: Resource Scheduling using Apache Mesos in Cloud Native Environments

Long term justification needed to create a new Mesos framework

Page 30: Resource Scheduling using Apache Mesos in Cloud Native Environments

Our motivations for new framework

● Cloud native○ Large variation in peak to trough usage○ Servers are more ephemeral

Page 31: Resource Scheduling using Apache Mesos in Cloud Native Environments

Our motivations for new framework

● Cloud native○ Large variation in peak to trough usage○ Servers are more ephemeral

● Resource usage optimizations

Page 32: Resource Scheduling using Apache Mesos in Cloud Native Environments

Cluster autoscaling challenge

Host 1 Host 2 Host 3 Host 4

Page 33: Resource Scheduling using Apache Mesos in Cloud Native Environments

Cluster autoscaling challenge

Host 1 Host 2 Host 3 Host 4

Host 1 Host 2 Host 3 Host 4vs.

Page 34: Resource Scheduling using Apache Mesos in Cloud Native Environments

Cluster autoscaling challenge

Host 1 Host 2 Host 3 Host 4

Host 1 Host 2 Host 3 Host 4vs.

Page 35: Resource Scheduling using Apache Mesos in Cloud Native Environments

Stream locality challenge

Data stream

Host A

Task1

Host B

Task2

Host C

Task3

Page 36: Resource Scheduling using Apache Mesos in Cloud Native Environments

Stream locality challenge

Data stream

Host A

Task1

Host B

Task2

Host C

Task3

Data stream

Host X

Task1

Task2

Task3

vs.

Reduces network bandwidth usage

Page 37: Resource Scheduling using Apache Mesos in Cloud Native Environments

Backpressure challenge

On back pressure, scale horizontally

Processor task

Sou

rce

Sta

ge 1

Sta

ge 2

Sta

ge 3

Sin

k

Hot source Vs. cold source

Page 38: Resource Scheduling using Apache Mesos in Cloud Native Environments

Fenzo task scheduler

Page 39: Resource Scheduling using Apache Mesos in Cloud Native Environments

Fenzo task scheduler

Generic task scheduler

Heterogeneous

AutoscaleVisibility

Plugins forConstraints, Fitness

High speed

Page 40: Resource Scheduling using Apache Mesos in Cloud Native Environments

Fenzo usage in frameworksMesos master

Mesos framework

Tasksrequests

Availableresource

offers

Fenzo taskscheduler

Task assignment result• Host1

• Task1• Task2

• Host2• Task3• Task4

Persistence

Page 41: Resource Scheduling using Apache Mesos in Cloud Native Environments

Scheduling problem

Fitness

Pending

Assigned

Urg

ency

N tasks to assign from M possible slaves

Page 42: Resource Scheduling using Apache Mesos in Cloud Native Environments

Scheduling optimizations

Speed Accuracy

First fit assignment Optimal assignment

Real world trade-offs~ O (1) ~ O (N * M)1

1 Assuming tasks are not reassigned

Page 43: Resource Scheduling using Apache Mesos in Cloud Native Environments

Scheduling strategyFor each task

Validate constraintsEval fitness on each host

Until fitness good enough, and

A minimum #hosts evaluated

Page 44: Resource Scheduling using Apache Mesos in Cloud Native Environments

Task constraints

SoftHard

Page 45: Resource Scheduling using Apache Mesos in Cloud Native Environments

Task constraints

SoftHardSome built-in

Host attribute basedCo-tasks based

Extensible

Page 46: Resource Scheduling using Apache Mesos in Cloud Native Environments

Fitness evaluation

Degree of fitness

Composable

Page 47: Resource Scheduling using Apache Mesos in Cloud Native Environments

Bin packing fitness calculator

Fitness for

Host1 Host2 Host3 Host4 Host5

fitness = usedCPUs / totalCPUs

Page 48: Resource Scheduling using Apache Mesos in Cloud Native Environments

Bin packing fitness calculator

Fitness for 0.25 0.5 0.75 1.0 0.0

Host1 Host2 Host3 Host4 Host5

fitness = usedCPUs / totalCPUs

Page 49: Resource Scheduling using Apache Mesos in Cloud Native Environments

Bin packing fitness calculator

Fitness for 0.25 0.5 0.75 1.0 0.0

Host1 Host2 Host3 Host4 Host5

fitness = usedCPUs / totalCPUs

Page 50: Resource Scheduling using Apache Mesos in Cloud Native Environments

Stream locality fitnessStream locality fitness

= percentage of tasks connecting to the same stream

Page 51: Resource Scheduling using Apache Mesos in Cloud Native Environments

Composable fitness calculatorsFitness

= ( BinPackFitness * BinPackWeight +RuntimePackFitness * RuntimeWeight +StreamLocalityFitness * StreamWeight) / 3.0

Page 52: Resource Scheduling using Apache Mesos in Cloud Native Environments

Cluster autoscaling in Fenzo

ASG/Cluster: mantisagentMinIdle: 8MaxIdle: 20CooldownSecs: 360

ASG/Cluster: mantisagentMinIdle: 8MaxIdle: 20CooldownSecs: 360

ASG/cluster: computeCluster

MinIdle: 8MaxIdle: 20CooldownSecs: 360

Fenzo

ScaleUp action:

Cluster, N

ScaleDown action:Cluster, HostList

Page 53: Resource Scheduling using Apache Mesos in Cloud Native Environments

Rules based cluster autoscaling● Set up rules per host attribute value

○ E.g., one autoscale rule per ASG/cluster, one cluster for network-intensive jobs, another for CPU/memory-intensive jobs

● Sample:○ ClusterName, MinIdle, MaxIdle, CoolDownSecs○ NwkClstr,10,20,360; CmputeClstr,5,20,300

#Idlehosts

Trigger down scale

Trigger up scalemin

max

Page 54: Resource Scheduling using Apache Mesos in Cloud Native Environments

Shortfall based cluster autoscaling

● Rule-based scale up has a cool down period○ What if there’s a surge of incoming requests?

● Pending requests trigger shortfall analysis○ Scale up happens regardless of cool down period○ Remembers which tasks have already been covered

Page 55: Resource Scheduling using Apache Mesos in Cloud Native Environments

Combining predictive autoscaling● EC2 Auto Scaling groups have 3 numbers to control● Fenzo sets “desirable” value● Set max value to limit scale up● Scryer can set min value

1 http://techblog.netflix.com/2013/11/scryer-netflixs-predictive-auto-scaling.html

Page 56: Resource Scheduling using Apache Mesos in Cloud Native Environments

Job autoscalingAutoscale resources of a job’s stage based on backpressure or its usage of CPU, memory, network

Page 57: Resource Scheduling using Apache Mesos in Cloud Native Environments

Job autoscalingjob’s network bandwidth usage

number of job processes

Example from a job that reads from a queue to process data across multiple processes

Page 58: Resource Scheduling using Apache Mesos in Cloud Native Environments

To summarize...

Page 59: Resource Scheduling using Apache Mesos in Cloud Native Environments

Why Apache Mesos in a Cloud?

Resource granularity

Task start latency

Page 60: Resource Scheduling using Apache Mesos in Cloud Native Environments

Fenzo task scheduler

Generic task scheduler

Heterogeneous

AutoscaleVisibility

Plugins forConstraints, Fitness

High speed

Page 61: Resource Scheduling using Apache Mesos in Cloud Native Environments

Mantis system overview

MantisMantis

Apache MesosApache Mesos

Mantis

Apache Mesos

ASGASG

ASGFenzo

MesosFramework

ZooKeeper

Inst

ance

Apache MesosSlave Cluster

Page 62: Resource Scheduling using Apache Mesos in Cloud Native Environments

Heterogeneous Resource Scheduling Using Apache Mesos for Cloud Native Frameworks

Sharma Podila

@podila