SlideShare une entreprise Scribd logo
1  sur  36
Télécharger pour lire hors ligne
WIFI SSID:Spark+AISummit | Password: UnifiedDataAnalytics
Jean-Yves Stephan & Julien Dumazert,
Founders of Data Mechanics
Automating performance
tuning for Apache Spark
#UnifiedDataAnalytics #SparkAISummit
What is performance tuning?
3
Cluster parameters
● Size
● Instance type
● # of processors
● # of memory
● Disks
● ...
Spark configurations
● Parallelism
● Shuffle
● Storage
● JVM tuning
● Feature flags
● ...
Why automate performance tuning?
4
Pick new
params
Analyze
logs
Run
the job
Why automate performance tuning?
5
Pick new
params
Analyze
logs
Run
the job
Pager ringing at 3am
30% of your engineers time
Missing SLAs every week
Hard manual work
Frequent outages
Slow and expensive
Agenda
Manual
performance tuning
6
Automated
performance tuning
Hands-on performance
tuning
Perf tuning is an iterative process
For the first run
There are rules of thumb for some params:
• # of partitions: 3x the number of cores in the cluster
• # of cores per executor: 4-8
• memory per executor: 85% * (node memory / #
executors by node)
For the other params: make an educated guess!
8
Perf tuning is an iterative process
On the first attempt, the job crashes or does not meet the SLA. What to do?
9
Pick new
params
Analyze
logs
Run
the job
• Ensure stability of the job
• Solve performance issues
• Adjust speed-cost trade-off
Common issues: lack of parallelism
10
Only 8 cores used
on each machine!
Configuration:
• 26 instances n1-highmem-16
• spark.executor.cores = 16
Common issues: lack of parallelism
Configuration:
• 26 instances n1-highmem-16
• spark.executor.cores = 16
11
Only 8 cores used
on each machine!
The reason:
• 26 executors
• spark.sql.shuffle.partitions = 200
→ 200 / 26 ~ 7.7 tasks per executor
Fix: Use 400+ partitions (duration and cost / 2)
See also Adaptive execution (SPARK-23128) for
a way to dynamically and automatically set the
number of partitions.
Common issues: shuffle spill
12
The deserialized data produced by the map
stages in a shuffle does not fit in memory.
Spark temporarily writes it to disk, which
degrades performance.
Fixes:
1. Reduce the input data of each task by
increasing the number of partitions
2. Increase the memory available to each task
– by increasing spark executor memory
– by decreasing the number of cores per
executor
Common issues: data skew
13
This issue is not addressable with parameter tuning. A change in code is required!
Change in code:
1. Find a better partition key if possible
2. Use a map-side (broadcast) join
3. Use a salted key
Improvements based on node metrics
14
● Low CPU Usage => Consider oversubscription, ie telling Spark to schedule say 2x more
tasks per executor than the number of cores
● Low Memory Usage => Consider pruning the excess memory and switching to
CPU-intensive instances
● IO bound queries => Consider switching instance type or Spark IO configurations such as
compression or IO buffer sizes
Cost-speed trade-off
15
On the efficient frontier:
cheaper ⇒ longer
shorter ⇒ more expensive
Once performance issues are
solved, adjust your trade-off
given your needs.
Efficient frontier
Solving performance
issues
Adjusting
cost-speed trade-off
Cost-speed trade-off
16
40 instances
10 instances
4 instances
Example: impact of # of instances
Recap: manual perf tuning
Iterative process:
17
Solve performance
issues
Adjust cost-speed
tradeoff
Most of the impact comes from a
few parameters:
• # and type of instances for
execs and driver
• executor and driver size
(memory, # of cores)
• # of partitions
Open source tuning tools
To detect performance issues: DrElephant (LinkedIn)
To simulate cost-speed trade-off: SparkLens
(only supports adjusting # of executors)
18
Automated performance
tuning
Motivations
Performance tuning can make periodic workloads 2x faster
and more stable.
But:
• tedious manual process
• requires expertise
→ to scale it to 100+ pipelines, automation is required!
20
Pick new
params
Analyze
logs
Run
the job
Architecture (tech)
21
Scheduler Spark jobGateway
Optimization
engine
Data Mechanics
Kubernetes cluster
Customer
code
Job history
Spark
listener
1) Unoptimized Spark job
description
2) Optimization engine
identifies job from history
and returns config
3) Optimized Spark
job description
4) An agent exports
event logs and system
metrics during job run
Architecture (algo)
23
Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th Jun 7th
Architecture (algo)
24
Heuristic
A
Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th
Heuristic
B
Jun 7th
Spark events log and metrics
Architecture (algo)
25
Heuristic
A
Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th
Evaluator
A
Heuristic
B
Evaluator
B
Param set A1
Param set A3
Param set B2
Jun 7th
Spark events log and metrics
Evaluators leverage
historical data
Architecture (algo)
26
Heuristic
A
Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th
Evaluator
A
Heuristic
B
Evaluator
B
Experiment
manager
Param set A1
Param set A3
Param set B2
Evaluated
param set B2
Evaluated
param set A1
Jun 7th
Spark events log and metrics
Evaluators leverage
historical data
Architecture (algo)
27
Heuristic
A
Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th
Evaluator
A
Heuristic
B
Evaluator
B
Experiment
manager
Param set A1
Param set A3
Param set B2
Evaluated
param set B2
Evaluated
param set A1
Jun 7th
Optimistic best
param set
Spark events log and metrics
Evaluators leverage
historical data
Heuristics
Heuristics look for performance issues:
• FewerTasksThanTotalCores
• ShuffleSpill
• LongShuffleReadTime
• LongGC
• ExecMemoryLargerThanNeeded
• TooShortTasks
• CPUTimeShorterThanComputeTime
• …
28
Or push in a given direction:
• IncreaseDefaultNumPartitions
• IncreaseTotalCores
• …
Heuristic
A
Jun 6th
Heuristic
B
Spark events log and metrics
Param sets
Every heuristic proposes different param sets.
Heuristics example
FewerTasksThanTotalCores
If a stage has fewer tasks than the total number of cores:
1. Increase the default number of partitions if applicable
2. Decrease the number of instances
3. Decrease the # of cores per instance (and adjust
memory)
29
Heuristic
A
Jun 6th
Heuristic
B
Spark events log and metrics
Param sets
Ranking param sets
Param sets cost and duration are evaluated by
Evaluators.
The Experiment manager selects the best solution
according to customer settings.
30
Evaluator
A
Evaluator
B
Experiment
manager
Optimistic best
param set
Unevaluated param sets
Evaluator
Estimates cost and duration distributions.
• From history if possible
• By simulation otherwise
The simulation: an optimistic model of the Spark scheduler.
• Takes as input a Spark app (Spark events log)
• Simulates a new execution under different conditions
• Different # of partitions, cores / exec, execs
• Optimistic assumptions: no GC time, no shuffle read time
Why optimistic? Encourages exploration!
31
Evaluator
Unevaluated param set
Evaluated param set
(cost and duration)
History
Experiment manager
Selects the best param set given customer objectives like:
• as cheap as possible within maximum duration
• as fast as possible within budget
• finish at 6am no matter what
Contains Bayesian optimization logic to account for noise.
32
Experiment
manager
Optimistic best
param set
Evaluated param sets
(cost and duration)
Architecture (algo)
33
Heuristic
A
Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th
Evaluator
A
Heuristic
B
Evaluator
B
Experiment
manager
Param set A1
Param set A3
Param set B2
Evaluated
param set B2
Evaluated
param set A1
Jun 7th
Optimistic best
param set
Spark events log and metrics
Evaluators leverage
historical data
34
● Stability: Automatic remediation of
OOMs and timeouts (upon retry)
● Performance: 50% cost reduction.
● Algorithm typically converges and
adapts to changes in 5-10 iterations.
Impact of automated tuning
Data Mechanics platform
35
● A managed platform for containerized
Spark apps in your cloud account
● Just send your code, we automate the
scaling and configurations tuning
● Pricing based on real Spark compute
time, not on idle server uptime.
Gateway
Data
source
Data engineers
Data scientists
The hassle-free Spark platform
powered by Kubernetes
Learn more and sign up for private beta on https://www.datamechanics.co
Also, we’re hiring :) jobs@datamechanics.co
DON’T FORGET TO RATE
AND REVIEW THE SESSIONS
SEARCH SPARK + AI SUMMIT

Contenu connexe

Tendances

The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/AvroThe Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
Databricks
 

Tendances (20)

Top 5 mistakes when writing Spark applications
Top 5 mistakes when writing Spark applicationsTop 5 mistakes when writing Spark applications
Top 5 mistakes when writing Spark applications
 
How to Performance-Tune Apache Spark Applications in Large Clusters
How to Performance-Tune Apache Spark Applications in Large ClustersHow to Performance-Tune Apache Spark Applications in Large Clusters
How to Performance-Tune Apache Spark Applications in Large Clusters
 
Understanding Query Plans and Spark UIs
Understanding Query Plans and Spark UIsUnderstanding Query Plans and Spark UIs
Understanding Query Plans and Spark UIs
 
Memory Management in Apache Spark
Memory Management in Apache SparkMemory Management in Apache Spark
Memory Management in Apache Spark
 
Understanding Memory Management In Spark For Fun And Profit
Understanding Memory Management In Spark For Fun And ProfitUnderstanding Memory Management In Spark For Fun And Profit
Understanding Memory Management In Spark For Fun And Profit
 
Spark tuning
Spark tuningSpark tuning
Spark tuning
 
Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...
Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...
Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...
 
Flash for Apache Spark Shuffle with Cosco
Flash for Apache Spark Shuffle with CoscoFlash for Apache Spark Shuffle with Cosco
Flash for Apache Spark Shuffle with Cosco
 
Physical Plans in Spark SQL
Physical Plans in Spark SQLPhysical Plans in Spark SQL
Physical Plans in Spark SQL
 
Top 5 mistakes when writing Spark applications
Top 5 mistakes when writing Spark applicationsTop 5 mistakes when writing Spark applications
Top 5 mistakes when writing Spark applications
 
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark ApplicationsTop 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
 
How Adobe Does 2 Million Records Per Second Using Apache Spark!
How Adobe Does 2 Million Records Per Second Using Apache Spark!How Adobe Does 2 Million Records Per Second Using Apache Spark!
How Adobe Does 2 Million Records Per Second Using Apache Spark!
 
Scaling Apache Spark at Facebook
Scaling Apache Spark at FacebookScaling Apache Spark at Facebook
Scaling Apache Spark at Facebook
 
How to Actually Tune Your Spark Jobs So They Work
How to Actually Tune Your Spark Jobs So They WorkHow to Actually Tune Your Spark Jobs So They Work
How to Actually Tune Your Spark Jobs So They Work
 
Spark Performance Tuning .pdf
Spark Performance Tuning .pdfSpark Performance Tuning .pdf
Spark Performance Tuning .pdf
 
Spark shuffle introduction
Spark shuffle introductionSpark shuffle introduction
Spark shuffle introduction
 
Deep Dive into the New Features of Apache Spark 3.0
Deep Dive into the New Features of Apache Spark 3.0Deep Dive into the New Features of Apache Spark 3.0
Deep Dive into the New Features of Apache Spark 3.0
 
Cosco: An Efficient Facebook-Scale Shuffle Service
Cosco: An Efficient Facebook-Scale Shuffle ServiceCosco: An Efficient Facebook-Scale Shuffle Service
Cosco: An Efficient Facebook-Scale Shuffle Service
 
Spark Shuffle Deep Dive (Explained In Depth) - How Shuffle Works in Spark
Spark Shuffle Deep Dive (Explained In Depth) - How Shuffle Works in SparkSpark Shuffle Deep Dive (Explained In Depth) - How Shuffle Works in Spark
Spark Shuffle Deep Dive (Explained In Depth) - How Shuffle Works in Spark
 
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/AvroThe Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
 

Similaire à How to Automate Performance Tuning for Apache Spark

Analyzing 2TB of Raw Trace Data from a Manufacturing Process: A First Use Cas...
Analyzing 2TB of Raw Trace Data from a Manufacturing Process: A First Use Cas...Analyzing 2TB of Raw Trace Data from a Manufacturing Process: A First Use Cas...
Analyzing 2TB of Raw Trace Data from a Manufacturing Process: A First Use Cas...
Databricks
 
Auto-Pilot for Apache Spark Using Machine Learning
Auto-Pilot for Apache Spark Using Machine LearningAuto-Pilot for Apache Spark Using Machine Learning
Auto-Pilot for Apache Spark Using Machine Learning
Databricks
 
The state of Spark in the cloud
The state of Spark in the cloudThe state of Spark in the cloud
The state of Spark in the cloud
Nicolas Poggi
 

Similaire à How to Automate Performance Tuning for Apache Spark (20)

Spark Autotuning: Spark Summit East talk by Lawrence Spracklen
Spark Autotuning: Spark Summit East talk by Lawrence SpracklenSpark Autotuning: Spark Summit East talk by Lawrence Spracklen
Spark Autotuning: Spark Summit East talk by Lawrence Spracklen
 
Spark Autotuning - Spark Summit East 2017
Spark Autotuning - Spark Summit East 2017 Spark Autotuning - Spark Summit East 2017
Spark Autotuning - Spark Summit East 2017
 
Profiling & Testing with Spark
Profiling & Testing with SparkProfiling & Testing with Spark
Profiling & Testing with Spark
 
BIRTE-13-Kawashima
BIRTE-13-KawashimaBIRTE-13-Kawashima
BIRTE-13-Kawashima
 
SnappyData Ad Analytics Use Case -- BDAM Meetup Sept 14th
SnappyData Ad Analytics Use Case -- BDAM Meetup Sept 14thSnappyData Ad Analytics Use Case -- BDAM Meetup Sept 14th
SnappyData Ad Analytics Use Case -- BDAM Meetup Sept 14th
 
Analyzing 2TB of Raw Trace Data from a Manufacturing Process: A First Use Cas...
Analyzing 2TB of Raw Trace Data from a Manufacturing Process: A First Use Cas...Analyzing 2TB of Raw Trace Data from a Manufacturing Process: A First Use Cas...
Analyzing 2TB of Raw Trace Data from a Manufacturing Process: A First Use Cas...
 
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ ProcessorsUnderstand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
 
LAS16-TR04: Using tracing to tune and optimize EAS (English)
LAS16-TR04: Using tracing to tune and optimize EAS (English)LAS16-TR04: Using tracing to tune and optimize EAS (English)
LAS16-TR04: Using tracing to tune and optimize EAS (English)
 
Auto-Pilot for Apache Spark Using Machine Learning
Auto-Pilot for Apache Spark Using Machine LearningAuto-Pilot for Apache Spark Using Machine Learning
Auto-Pilot for Apache Spark Using Machine Learning
 
What’s eating python performance
What’s eating python performanceWhat’s eating python performance
What’s eating python performance
 
OracleCode 2017: Performance Diagnostic Techniques for Big Data Solutions Usi...
OracleCode 2017: Performance Diagnostic Techniques for Big Data Solutions Usi...OracleCode 2017: Performance Diagnostic Techniques for Big Data Solutions Usi...
OracleCode 2017: Performance Diagnostic Techniques for Big Data Solutions Usi...
 
The state of Spark in the cloud
The state of Spark in the cloudThe state of Spark in the cloud
The state of Spark in the cloud
 
Kafka to the Maxka - (Kafka Performance Tuning)
Kafka to the Maxka - (Kafka Performance Tuning)Kafka to the Maxka - (Kafka Performance Tuning)
Kafka to the Maxka - (Kafka Performance Tuning)
 
Pragmatic Optimization in Modern Programming - Ordering Optimization Approaches
Pragmatic Optimization in Modern Programming - Ordering Optimization ApproachesPragmatic Optimization in Modern Programming - Ordering Optimization Approaches
Pragmatic Optimization in Modern Programming - Ordering Optimization Approaches
 
Spark Summit EU talk by Luca Canali
Spark Summit EU talk by Luca CanaliSpark Summit EU talk by Luca Canali
Spark Summit EU talk by Luca Canali
 
BAXTER phase 1b
BAXTER phase 1bBAXTER phase 1b
BAXTER phase 1b
 
Migrating Complex Data Aggregation from Hadoop to Spark-(Ashish Singh andPune...
Migrating Complex Data Aggregation from Hadoop to Spark-(Ashish Singh andPune...Migrating Complex Data Aggregation from Hadoop to Spark-(Ashish Singh andPune...
Migrating Complex Data Aggregation from Hadoop to Spark-(Ashish Singh andPune...
 
SCALABLE MONITORING USING PROMETHEUS WITH APACHE SPARK
SCALABLE MONITORING USING PROMETHEUS WITH APACHE SPARKSCALABLE MONITORING USING PROMETHEUS WITH APACHE SPARK
SCALABLE MONITORING USING PROMETHEUS WITH APACHE SPARK
 
Running Apache Spark on Kubernetes: Best Practices and Pitfalls
Running Apache Spark on Kubernetes: Best Practices and PitfallsRunning Apache Spark on Kubernetes: Best Practices and Pitfalls
Running Apache Spark on Kubernetes: Best Practices and Pitfalls
 
Cost-Based Optimizer in Apache Spark 2.2
Cost-Based Optimizer in Apache Spark 2.2 Cost-Based Optimizer in Apache Spark 2.2
Cost-Based Optimizer in Apache Spark 2.2
 

Plus de Databricks

Democratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized PlatformDemocratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized Platform
Databricks
 
Stage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI IntegrationStage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI Integration
Databricks
 
Simplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorchSimplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorch
Databricks
 
Raven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction QueriesRaven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction Queries
Databricks
 
Processing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache SparkProcessing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache Spark
Databricks
 

Plus de Databricks (20)

DW Migration Webinar-March 2022.pptx
DW Migration Webinar-March 2022.pptxDW Migration Webinar-March 2022.pptx
DW Migration Webinar-March 2022.pptx
 
Data Lakehouse Symposium | Day 1 | Part 1
Data Lakehouse Symposium | Day 1 | Part 1Data Lakehouse Symposium | Day 1 | Part 1
Data Lakehouse Symposium | Day 1 | Part 1
 
Data Lakehouse Symposium | Day 1 | Part 2
Data Lakehouse Symposium | Day 1 | Part 2Data Lakehouse Symposium | Day 1 | Part 2
Data Lakehouse Symposium | Day 1 | Part 2
 
Data Lakehouse Symposium | Day 2
Data Lakehouse Symposium | Day 2Data Lakehouse Symposium | Day 2
Data Lakehouse Symposium | Day 2
 
Data Lakehouse Symposium | Day 4
Data Lakehouse Symposium | Day 4Data Lakehouse Symposium | Day 4
Data Lakehouse Symposium | Day 4
 
5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop
5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop
5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop
 
Democratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized PlatformDemocratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized Platform
 
Learn to Use Databricks for Data Science
Learn to Use Databricks for Data ScienceLearn to Use Databricks for Data Science
Learn to Use Databricks for Data Science
 
Why APM Is Not the Same As ML Monitoring
Why APM Is Not the Same As ML MonitoringWhy APM Is Not the Same As ML Monitoring
Why APM Is Not the Same As ML Monitoring
 
The Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
The Function, the Context, and the Data—Enabling ML Ops at Stitch FixThe Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
The Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
 
Stage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI IntegrationStage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI Integration
 
Simplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorchSimplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorch
 
Scaling your Data Pipelines with Apache Spark on Kubernetes
Scaling your Data Pipelines with Apache Spark on KubernetesScaling your Data Pipelines with Apache Spark on Kubernetes
Scaling your Data Pipelines with Apache Spark on Kubernetes
 
Scaling and Unifying SciKit Learn and Apache Spark Pipelines
Scaling and Unifying SciKit Learn and Apache Spark PipelinesScaling and Unifying SciKit Learn and Apache Spark Pipelines
Scaling and Unifying SciKit Learn and Apache Spark Pipelines
 
Sawtooth Windows for Feature Aggregations
Sawtooth Windows for Feature AggregationsSawtooth Windows for Feature Aggregations
Sawtooth Windows for Feature Aggregations
 
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen SinkRedis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
 
Re-imagine Data Monitoring with whylogs and Spark
Re-imagine Data Monitoring with whylogs and SparkRe-imagine Data Monitoring with whylogs and Spark
Re-imagine Data Monitoring with whylogs and Spark
 
Raven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction QueriesRaven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction Queries
 
Processing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache SparkProcessing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache Spark
 
Massive Data Processing in Adobe Using Delta Lake
Massive Data Processing in Adobe Using Delta LakeMassive Data Processing in Adobe Using Delta Lake
Massive Data Processing in Adobe Using Delta Lake
 

Dernier

Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
MarinCaroMartnezBerg
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
JoseMangaJr1
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
amitlee9823
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
amitlee9823
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 

Dernier (20)

ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptx
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 

How to Automate Performance Tuning for Apache Spark

  • 1. WIFI SSID:Spark+AISummit | Password: UnifiedDataAnalytics
  • 2. Jean-Yves Stephan & Julien Dumazert, Founders of Data Mechanics Automating performance tuning for Apache Spark #UnifiedDataAnalytics #SparkAISummit
  • 3. What is performance tuning? 3 Cluster parameters ● Size ● Instance type ● # of processors ● # of memory ● Disks ● ... Spark configurations ● Parallelism ● Shuffle ● Storage ● JVM tuning ● Feature flags ● ...
  • 4. Why automate performance tuning? 4 Pick new params Analyze logs Run the job
  • 5. Why automate performance tuning? 5 Pick new params Analyze logs Run the job Pager ringing at 3am 30% of your engineers time Missing SLAs every week Hard manual work Frequent outages Slow and expensive
  • 8. Perf tuning is an iterative process For the first run There are rules of thumb for some params: • # of partitions: 3x the number of cores in the cluster • # of cores per executor: 4-8 • memory per executor: 85% * (node memory / # executors by node) For the other params: make an educated guess! 8
  • 9. Perf tuning is an iterative process On the first attempt, the job crashes or does not meet the SLA. What to do? 9 Pick new params Analyze logs Run the job • Ensure stability of the job • Solve performance issues • Adjust speed-cost trade-off
  • 10. Common issues: lack of parallelism 10 Only 8 cores used on each machine! Configuration: • 26 instances n1-highmem-16 • spark.executor.cores = 16
  • 11. Common issues: lack of parallelism Configuration: • 26 instances n1-highmem-16 • spark.executor.cores = 16 11 Only 8 cores used on each machine! The reason: • 26 executors • spark.sql.shuffle.partitions = 200 → 200 / 26 ~ 7.7 tasks per executor Fix: Use 400+ partitions (duration and cost / 2) See also Adaptive execution (SPARK-23128) for a way to dynamically and automatically set the number of partitions.
  • 12. Common issues: shuffle spill 12 The deserialized data produced by the map stages in a shuffle does not fit in memory. Spark temporarily writes it to disk, which degrades performance. Fixes: 1. Reduce the input data of each task by increasing the number of partitions 2. Increase the memory available to each task – by increasing spark executor memory – by decreasing the number of cores per executor
  • 13. Common issues: data skew 13 This issue is not addressable with parameter tuning. A change in code is required! Change in code: 1. Find a better partition key if possible 2. Use a map-side (broadcast) join 3. Use a salted key
  • 14. Improvements based on node metrics 14 ● Low CPU Usage => Consider oversubscription, ie telling Spark to schedule say 2x more tasks per executor than the number of cores ● Low Memory Usage => Consider pruning the excess memory and switching to CPU-intensive instances ● IO bound queries => Consider switching instance type or Spark IO configurations such as compression or IO buffer sizes
  • 15. Cost-speed trade-off 15 On the efficient frontier: cheaper ⇒ longer shorter ⇒ more expensive Once performance issues are solved, adjust your trade-off given your needs. Efficient frontier Solving performance issues Adjusting cost-speed trade-off
  • 16. Cost-speed trade-off 16 40 instances 10 instances 4 instances Example: impact of # of instances
  • 17. Recap: manual perf tuning Iterative process: 17 Solve performance issues Adjust cost-speed tradeoff Most of the impact comes from a few parameters: • # and type of instances for execs and driver • executor and driver size (memory, # of cores) • # of partitions
  • 18. Open source tuning tools To detect performance issues: DrElephant (LinkedIn) To simulate cost-speed trade-off: SparkLens (only supports adjusting # of executors) 18
  • 20. Motivations Performance tuning can make periodic workloads 2x faster and more stable. But: • tedious manual process • requires expertise → to scale it to 100+ pipelines, automation is required! 20 Pick new params Analyze logs Run the job
  • 21. Architecture (tech) 21 Scheduler Spark jobGateway Optimization engine Data Mechanics Kubernetes cluster Customer code Job history Spark listener 1) Unoptimized Spark job description 2) Optimization engine identifies job from history and returns config 3) Optimized Spark job description 4) An agent exports event logs and system metrics during job run
  • 22. Architecture (algo) 23 Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th Jun 7th
  • 23. Architecture (algo) 24 Heuristic A Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th Heuristic B Jun 7th Spark events log and metrics
  • 24. Architecture (algo) 25 Heuristic A Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th Evaluator A Heuristic B Evaluator B Param set A1 Param set A3 Param set B2 Jun 7th Spark events log and metrics Evaluators leverage historical data
  • 25. Architecture (algo) 26 Heuristic A Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th Evaluator A Heuristic B Evaluator B Experiment manager Param set A1 Param set A3 Param set B2 Evaluated param set B2 Evaluated param set A1 Jun 7th Spark events log and metrics Evaluators leverage historical data
  • 26. Architecture (algo) 27 Heuristic A Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th Evaluator A Heuristic B Evaluator B Experiment manager Param set A1 Param set A3 Param set B2 Evaluated param set B2 Evaluated param set A1 Jun 7th Optimistic best param set Spark events log and metrics Evaluators leverage historical data
  • 27. Heuristics Heuristics look for performance issues: • FewerTasksThanTotalCores • ShuffleSpill • LongShuffleReadTime • LongGC • ExecMemoryLargerThanNeeded • TooShortTasks • CPUTimeShorterThanComputeTime • … 28 Or push in a given direction: • IncreaseDefaultNumPartitions • IncreaseTotalCores • … Heuristic A Jun 6th Heuristic B Spark events log and metrics Param sets Every heuristic proposes different param sets.
  • 28. Heuristics example FewerTasksThanTotalCores If a stage has fewer tasks than the total number of cores: 1. Increase the default number of partitions if applicable 2. Decrease the number of instances 3. Decrease the # of cores per instance (and adjust memory) 29 Heuristic A Jun 6th Heuristic B Spark events log and metrics Param sets
  • 29. Ranking param sets Param sets cost and duration are evaluated by Evaluators. The Experiment manager selects the best solution according to customer settings. 30 Evaluator A Evaluator B Experiment manager Optimistic best param set Unevaluated param sets
  • 30. Evaluator Estimates cost and duration distributions. • From history if possible • By simulation otherwise The simulation: an optimistic model of the Spark scheduler. • Takes as input a Spark app (Spark events log) • Simulates a new execution under different conditions • Different # of partitions, cores / exec, execs • Optimistic assumptions: no GC time, no shuffle read time Why optimistic? Encourages exploration! 31 Evaluator Unevaluated param set Evaluated param set (cost and duration) History
  • 31. Experiment manager Selects the best param set given customer objectives like: • as cheap as possible within maximum duration • as fast as possible within budget • finish at 6am no matter what Contains Bayesian optimization logic to account for noise. 32 Experiment manager Optimistic best param set Evaluated param sets (cost and duration)
  • 32. Architecture (algo) 33 Heuristic A Jun 2nd Jun 3rd Jun 4th Jun 5th Jun 6th Evaluator A Heuristic B Evaluator B Experiment manager Param set A1 Param set A3 Param set B2 Evaluated param set B2 Evaluated param set A1 Jun 7th Optimistic best param set Spark events log and metrics Evaluators leverage historical data
  • 33. 34 ● Stability: Automatic remediation of OOMs and timeouts (upon retry) ● Performance: 50% cost reduction. ● Algorithm typically converges and adapts to changes in 5-10 iterations. Impact of automated tuning
  • 34. Data Mechanics platform 35 ● A managed platform for containerized Spark apps in your cloud account ● Just send your code, we automate the scaling and configurations tuning ● Pricing based on real Spark compute time, not on idle server uptime. Gateway Data source Data engineers Data scientists
  • 35. The hassle-free Spark platform powered by Kubernetes Learn more and sign up for private beta on https://www.datamechanics.co Also, we’re hiring :) jobs@datamechanics.co
  • 36. DON’T FORGET TO RATE AND REVIEW THE SESSIONS SEARCH SPARK + AI SUMMIT