39
DYNAMIC RESOURCE ALLOCATION, DO MORE WITH YOUR CLUSTER Luc Bourlier Lightbend

Spark Summit EU talk by Luc Bourlier

Embed Size (px)

Citation preview

Page 1: Spark Summit EU talk by Luc Bourlier

DYNAMIC RESOURCE ALLOCATION,DO MORE WITHYOUR CLUSTER

Luc BourlierLightbend

Page 2: Spark Summit EU talk by Luc Bourlier

● Dynamic Resource Allocation● ^^ in Spark● External Shuffle Service● Configuration● Demo● Spark Streaming

Page 3: Spark Summit EU talk by Luc Bourlier

Dynamic Resource Allocation

Page 4: Spark Summit EU talk by Luc Bourlier

Dynamic Resource Allocation

ClusterI’d like some resources for a job

Page 5: Spark Summit EU talk by Luc Bourlier

Dynamic Resource Allocation

Cluster

Oki. Thanks

Page 6: Spark Summit EU talk by Luc Bourlier

Dynamic Resource Allocation

Cluster

Page 7: Spark Summit EU talk by Luc Bourlier

Dynamic Resource Allocation

Cluster

Page 8: Spark Summit EU talk by Luc Bourlier

Dynamic Resource Allocation

Cluster

Page 9: Spark Summit EU talk by Luc Bourlier

Dynamic Resource Allocation

ClusterHmm, actually, I don’t need all this power anymore.

Page 10: Spark Summit EU talk by Luc Bourlier

Dynamic Resource Allocation

Cluster

Page 11: Spark Summit EU talk by Luc Bourlier

Why?● Shared cluster● Optimization of resource

usageWhen?● variable load job

Dynamic Resource AllocationCluster

Page 12: Spark Summit EU talk by Luc Bourlier

Spark Cluster Architecture

Page 13: Spark Summit EU talk by Luc Bourlier

Spark Cluster Architecture

Page 14: Spark Summit EU talk by Luc Bourlier

Spark Dynamic AllocationCluster Manager Worker Node

Executor

Worker Node

Worker Node

Executor

Driver

Scheduler(s)

need 2 executors

Page 15: Spark Summit EU talk by Luc Bourlier

tasks are waiting too long

Spark Dynamic AllocationCluster Manager Worker Node

Executor

Worker Node

Worker Node

Executor

Driver

Scheduler(s)

need 1 more executor

Executor

Page 16: Spark Summit EU talk by Luc Bourlier

executor has been idle for a while

Spark Dynamic AllocationCluster Manager Worker Node

Executor

Worker Node

Worker Node

Executor

Driver

Scheduler(s)

Executor

terminate the executor

Page 17: Spark Summit EU talk by Luc Bourlier

External Shuffle Service

Page 18: Spark Summit EU talk by Luc Bourlier

External Shuffle Service● Did we lose any data?

Page 19: Spark Summit EU talk by Luc Bourlier

External Shuffle Service

Shuffle write

Shuffle fetch

Map Task

Reduce Task

Aggregator

bucket bucket bucket

Aggregator

Map Task

Reduce Task

Aggregator

bucket bucket bucket

Aggregator

Map Task

Reduce Task

Aggregator

bucket bucket bucket

Aggregator

Page 20: Spark Summit EU talk by Luc Bourlier

External Shuffle Service

Shuffle write

Shuffle fetch

Map Task

Reduce Task

Aggregator

bucket bucket bucket

Aggregator

Map Task

Reduce Task

Aggregator

bucket bucket bucket

Aggregator

Map Task

Reduce Task

Aggregator

bucket bucket bucket

Aggregator

Page 21: Spark Summit EU talk by Luc Bourlier

External Shuffle Service

Shuffle write

Shuffle fetch

Map Task

Reduce Task

Aggregator

bucket bucket bucket

Aggregator

Map Task

Reduce Task

Aggregator

bucket bucket bucket

Aggregator

Map Task

Reduce Task

Aggregator

bucket bucket bucket

Aggregator

Page 22: Spark Summit EU talk by Luc Bourlier

External Shuffle Service● Extracted from executor● Manage the local aggregated data for the

shuffle operations● Maintain the data until the application is done.

Page 23: Spark Summit EU talk by Luc Bourlier

Configuration

Page 24: Spark Summit EU talk by Luc Bourlier

Configuration● Dynamic Allocation

○ spark.dynamicAllocation.enabled

○ spark.dynamicAllocation.initialExecutors

○ spark.dynamicAllocation.maxExecutors

○ spark.dynamicAllocation.minExecutors

Page 25: Spark Summit EU talk by Luc Bourlier

Configuration● Dynamic Allocation

○ spark.dynamicAllocation.schedulerBacklogTimeout

○ spark.dynamicAllocation.executorIdleTimeout

○ spark.dynamicAllocation.sustainedSchedulerBacklogTimeout

Page 26: Spark Summit EU talk by Luc Bourlier

Configuration● External Shuffle Service

○ spark.shuffle.service.enabled

○ spark.shuffle.service.port

Page 27: Spark Summit EU talk by Luc Bourlier

DemoDynamic Allocation in Action

Page 28: Spark Summit EU talk by Luc Bourlier

Configuration values?

Page 29: Spark Summit EU talk by Luc Bourlier

Configuration Values?It depends ….

No, seriously

Page 30: Spark Summit EU talk by Luc Bourlier

Configuration Values● spark.dynamicAllocation.initialExecutors

● spark.dynamicAllocation.maxExecutors

● spark.dynamicAllocation.minExecutors

Depends on workload and how many resources are potentially available to you.

Page 31: Spark Summit EU talk by Luc Bourlier

Configuration Values● spark.dynamicAllocation.schedulerBacklogTimeout

Too short, might trigger for short burst of tasks.Too long, might be less effective.

● spark.dynamicAllocation.sustainedSchedulerBacklogTimeout

Executor start duration.Default set to schedulerBacklogTimeout.

Page 32: Spark Summit EU talk by Luc Bourlier

Configuration Values● spark.dynamicAllocation.executorIdleTimeout

Relative to the duration of the longer task.No big drawback on being too long, except cost.

Page 33: Spark Summit EU talk by Luc Bourlier

Spark Streaming

Page 34: Spark Summit EU talk by Luc Bourlier

Spark Streaming

http://spark.apache.org/docs/latest/streaming-programming-guide.html

Page 35: Spark Summit EU talk by Luc Bourlier

• In most case, schedulerBacklogTimeout longer than batch interval.

• executorIdleTimeout a portion of batch interval.

• Should allow to manage processing delay.

• Not compatible with the dynamic rate estimator.

Spark Streaming

Page 36: Spark Summit EU talk by Luc Bourlier

More Dynamic?

Page 37: Spark Summit EU talk by Luc Bourlier

More Dynamic?https://github.com/twosigma/Cook

‘Fair’ job scheduler for Spark on top of Mesos

● Not a recommendation, just a suggestion.● Some assembly required.

Page 39: Spark Summit EU talk by Luc Bourlier

External Shuffle ServiceCluster Manager Worker Node

Executor

Worker Node

Worker NodeDriver

Scheduler(s)

Executor

External Shuffle Service

External Shuffle Service

External Shuffle Service