Microsoft Fabric Apache Spark Performance remediate
Systematic workflows for diagnosing, analyzing, and resolving Apache Spark performance problems in Microsoft Fabric Data Engineering and Data Science workloads.
When to Use This Skill
Activate when encountering any of the following scenarios:
- Spark notebooks or jobs running slower than expected
- Capacity throttling errors (HTTP 430 / TooManyRequestsForCapacity)
- Data skew detected by Spark Advisor in notebook cells
- Excessive shuffle read/write in Spark UI stages
- Small files accumulation in Delta Lake tables
- Streaming ingestion throughput degradation
- Need to select or tune a Fabric Spark resource profile
- VOrder vs. Optimized Write decision-making
- Autotune configuration and validation
- Right-sizing Spark pools, node counts, or Fabric capacity SKUs
Prerequisites
- Access to a Microsoft Fabric workspace with Data Engineering enabled
- Contributor or higher role on the workspace
- Familiarity with PySpark or Spark SQL
- PowerShell 7+ (for diagnostic scripts)
- Fabric REST API access token (for API-based diagnostics)
Quick Diagnosis Decision Tree
Start here when a Spark job is slow:
Is the job queued or throttled? Check Monitoring Hub for HTTP 430.
Did the Spark Advisor flag warnings? Check notebook cell indicators.
Is a single stage disproportionately slow? Open Spark UI → Stages tab.
Are executors underutilized? Check Resources tab in monitoring detail.
Is the issue write-related? Check write duration in Spark UI.
Core Spark Configuration Quick Reference
These are the three settings Fabric Autotune manages automatically. If autotune is disabled, tune them manually:
| Setting |
Default |
Purpose |
Tuning Guidance |
spark.sql.shuffle.partitions |
200 |
Partition count during joins/aggregations |
Set to 2-3x total executor cores for your pool |
spark.sql.autoBroadcastJoinThreshold |
10 MB |
Max table size for broadcast joins |
Increase to 100-256 MB for star-schema joins |
spark.sql.files.maxPartitionBytes |
128 MB |
Max bytes per file-read partition |
Increase for large sequential scans, decrease for high parallelism |
Resource Profiles Quick Reference
Fabric provides predefined profiles that bundle optimized Spark settings:
| Profile |
Best For |
VOrder |
Key Characteristics |
writeHeavy |
ETL, batch ingestion, streaming |
Disabled |
Default for new workspaces; optimized write throughput |
readHeavyForSpark |
Interactive Spark queries, analytics |
Enabled |
Optimized read paths for Spark workloads |
readHeavyForPBI |
Power BI dashboards, DW queries |
Enabled |
Optimized for DirectLake and cross-engine reads |
Apply a profile at the environment level or override per-session:
# Per-session override example
spark.conf.set("spark.fabric.resource.profile", "readHeavyForSpark")
Autotune Quick Start
Enable autotune to let Fabric automatically optimize shuffle partitions, broadcast thresholds, and partition bytes:
# Enable in a notebook session
spark.conf.set("spark.ms.autotune.enabled", "true")
# Or set in Environment > Spark Properties
# spark.ms.autotune.enabled = true
Requirements: Runtime 1.1 or 1.2 only. Not compatible with high concurrency mode or private endpoints. Needs 20-25 iterations to converge on optimal settings.
Check autotune status after a query:
# View autotune decisions in Spark UI SQL tab
# Status values: QUERY_TUNING_SUCCEED, QUERY_TUNING_DISABLED,
# QUERY_PATTERN_NOT_MATCH, QUERY_DURATION_TOO_SHORT
Common Error Patterns
| Error / Symptom |
Root Cause |
Quick Fix |
| HTTP 430: TooManyRequestsForCapacity |
All Spark VCores consumed |
Cancel idle jobs in Monitoring Hub or upgrade SKU |
| Stage with 200 tasks, 1 task 100x slower |
Data skew on join/group key |
Add salting or use broadcast join |
| OOM on executor |
Partition too large or broadcast too big |
Increase partitions or lower broadcast threshold |
| Write takes >60% of total job time |
Small files or missing optimization |
Enable Optimized Write or run table maintenance |
| Streaming micro-batch latency increasing |
Checkpoint overhead or partition mismatch |
Tune trigger interval and Event Hub partitions |
Step-by-Step Workflows
For detailed procedures, see the reference guides:
- Spark Configuration Tuning — Shuffle, broadcast, skew, pool sizing, capacity planning
- Monitoring and Diagnostics — Spark UI navigation, Monitoring Hub, APIs, log analysis
- Delta Lake Optimization — VOrder, Optimized Write, table maintenance, partitioning, streaming
Available Scripts
Run the Fabric Spark diagnostics script to collect Spark application metrics via the Fabric REST API:
./scripts/Get-FabricSparkDiagnostics.ps1 -WorkspaceId "<guid>" -Token "<bearer-token>"
Available Templates
Use the performance analysis notebook template as a starting point for in-session diagnostics:
# Paste into a Fabric notebook to analyze current session performance
remediate
| Problem |
Check |
Resolution |
| Autotune not activating |
Runtime version, HC mode, private endpoint |
Switch to Runtime 1.1/1.2, disable HC mode |
| Resource profile not applying |
Environment publish status |
Republish environment after profile change |
| Pool autoscale not scaling up |
Capacity SKU limits |
Verify VCore headroom in Capacity Metrics app |
| Table maintenance job stuck |
Concurrent maintenance on same table |
Wait for previous job or cancel via API |
| Notebook cell shows no Spark Advisor |
Runtime < 3.4 |
Upgrade to Spark 3.4+ runtime |
References
1---2name: fabric-spark-perf-remediate3description: Diagnose and resolve Apache Spark performance issues in Microsoft Fabric. Use when asked to troubleshoot slow Spark notebooks, optimize Spark SQL queries, fix data skew or shuffle bottlenecks, tune spark.sql.shuffle.partitions or autoBroadcastJoinThreshold, configure resource profiles (writeHeavy, readHeavyForSpark, readHeavyForPBI), enable autotune, resolve HTTP 430 throttling errors, analyze Spark UI stages and executors, optimize Delta Lake writes with VOrder or Optimized Write, run table maintenance (bin-compaction, vacuum, Z-Order), fix small files problems, tune streaming throughput, or right-size Fabric Spark pools and capacity SKUs.4license: Complete terms in LICENSE.txt5---6
7# Microsoft Fabric Apache Spark Performance remediate
8
9Systematic workflows for diagnosing, analyzing, and resolving Apache Spark performance problems in Microsoft Fabric Data Engineering and Data Science workloads.
10
11## When to Use This Skill
12
13Activate when encountering any of the following scenarios:
14
15- Spark notebooks or jobs running slower than expected
16- Capacity throttling errors (HTTP 430 / TooManyRequestsForCapacity)
17- Data skew detected by Spark Advisor in notebook cells
18- Excessive shuffle read/write in Spark UI stages
19- Small files accumulation in Delta Lake tables
20- Streaming ingestion throughput degradation
21- Need to select or tune a Fabric Spark resource profile
22- VOrder vs. Optimized Write decision-making
23- Autotune configuration and validation
24- Right-sizing Spark pools, node counts, or Fabric capacity SKUs
25
26## Prerequisites
27
28- Access to a Microsoft Fabric workspace with Data Engineering enabled
29- Contributor or higher role on the workspace
30- Familiarity with PySpark or Spark SQL
31- PowerShell 7+ (for diagnostic scripts)
32- Fabric REST API access token (for API-based diagnostics)
33
34## Quick Diagnosis Decision Tree
35
36Start here when a Spark job is slow:
37
381. **Is the job queued or throttled?** Check Monitoring Hub for HTTP 430.
39 - Yes → See [Capacity and Concurrency Tuning](./references/spark-configuration-tuning.md#capacity-and-concurrency)
40 - No → Continue
41
422. **Did the Spark Advisor flag warnings?** Check notebook cell indicators.
43 - Data Skew detected → See [Data Skew Resolution](./references/spark-configuration-tuning.md#data-skew-resolution)
44 - No warnings → Continue
45
463. **Is a single stage disproportionately slow?** Open Spark UI → Stages tab.
47 - Yes, shuffle stage → See [Shuffle Optimization](./references/spark-configuration-tuning.md#shuffle-optimization)
48 - Yes, scan stage → See [File Scan Optimization](./references/delta-lake-optimization.md#file-scan-optimization)
49 - No → Continue
50
514. **Are executors underutilized?** Check Resources tab in monitoring detail.
52 - High idle cores → See [Pool and Executor Sizing](./references/spark-configuration-tuning.md#pool-and-executor-sizing)
53 - All cores busy → See [Partitioning Strategy](./references/spark-configuration-tuning.md#partitioning-strategy)
54
555. **Is the issue write-related?** Check write duration in Spark UI.
56 - Yes → See [Delta Write Optimization](./references/delta-lake-optimization.md#delta-write-optimization)
57 - No → See [General Spark SQL Tuning](./references/spark-configuration-tuning.md#spark-sql-tuning)
58
59## Core Spark Configuration Quick Reference
60
61These are the three settings Fabric Autotune manages automatically. If autotune is disabled, tune them manually:
62
63| Setting | Default | Purpose | Tuning Guidance |
64|---------|---------|---------|-----------------|
65| `spark.sql.shuffle.partitions` | 200 | Partition count during joins/aggregations | Set to 2-3x total executor cores for your pool |
66| `spark.sql.autoBroadcastJoinThreshold` | 10 MB | Max table size for broadcast joins | Increase to 100-256 MB for star-schema joins |
67| `spark.sql.files.maxPartitionBytes` | 128 MB | Max bytes per file-read partition | Increase for large sequential scans, decrease for high parallelism |
68
69## Resource Profiles Quick Reference
70
71Fabric provides predefined profiles that bundle optimized Spark settings:
72
73| Profile | Best For | VOrder | Key Characteristics |
74|---------|----------|--------|---------------------|
75| `writeHeavy` | ETL, batch ingestion, streaming | Disabled | Default for new workspaces; optimized write throughput |
76| `readHeavyForSpark` | Interactive Spark queries, analytics | Enabled | Optimized read paths for Spark workloads |
77| `readHeavyForPBI` | Power BI dashboards, DW queries | Enabled | Optimized for DirectLake and cross-engine reads |
78
79Apply a profile at the environment level or override per-session:
80
81```python
82# Per-session override example
83spark.conf.set("spark.fabric.resource.profile", "readHeavyForSpark")
84```
85
86## Autotune Quick Start
87
88Enable autotune to let Fabric automatically optimize shuffle partitions, broadcast thresholds, and partition bytes:
89
90```python
91# Enable in a notebook session
92spark.conf.set("spark.ms.autotune.enabled", "true")
93
94# Or set in Environment > Spark Properties
95# spark.ms.autotune.enabled = true
96```
97
98**Requirements**: Runtime 1.1 or 1.2 only. Not compatible with high concurrency mode or private endpoints. Needs 20-25 iterations to converge on optimal settings.
99
100**Check autotune status** after a query:
101
102```python
103# View autotune decisions in Spark UI SQL tab
104# Status values: QUERY_TUNING_SUCCEED, QUERY_TUNING_DISABLED,
105# QUERY_PATTERN_NOT_MATCH, QUERY_DURATION_TOO_SHORT
106```
107
108## Common Error Patterns
109
110| Error / Symptom | Root Cause | Quick Fix |
111|-----------------|------------|-----------|
112| HTTP 430: TooManyRequestsForCapacity | All Spark VCores consumed | Cancel idle jobs in Monitoring Hub or upgrade SKU |
113| Stage with 200 tasks, 1 task 100x slower | Data skew on join/group key | Add salting or use broadcast join |
114| OOM on executor | Partition too large or broadcast too big | Increase partitions or lower broadcast threshold |
115| Write takes >60% of total job time | Small files or missing optimization | Enable Optimized Write or run table maintenance |
116| Streaming micro-batch latency increasing | Checkpoint overhead or partition mismatch | Tune trigger interval and Event Hub partitions |
117
118## Step-by-Step Workflows
119
120For detailed procedures, see the reference guides:
121
122- [Spark Configuration Tuning](./references/spark-configuration-tuning.md) — Shuffle, broadcast, skew, pool sizing, capacity planning
123- [Monitoring and Diagnostics](./references/monitoring-and-diagnostics.md) — Spark UI navigation, Monitoring Hub, APIs, log analysis
124- [Delta Lake Optimization](./references/delta-lake-optimization.md) — VOrder, Optimized Write, table maintenance, partitioning, streaming
125
126## Available Scripts
127
128Run the [Fabric Spark diagnostics script](./scripts/Get-FabricSparkDiagnostics.ps1) to collect Spark application metrics via the Fabric REST API:
129
130```powershell
131./scripts/Get-FabricSparkDiagnostics.ps1 -WorkspaceId "<guid>" -Token "<bearer-token>"
132```
133
134## Available Templates
135
136Use the [performance analysis notebook template](./templates/spark-perf-notebook.py) as a starting point for in-session diagnostics:
137
138```python
139# Paste into a Fabric notebook to analyze current session performance
140```
141
142## remediate
143
144| Problem | Check | Resolution |
145|---------|-------|------------|
146| Autotune not activating | Runtime version, HC mode, private endpoint | Switch to Runtime 1.1/1.2, disable HC mode |
147| Resource profile not applying | Environment publish status | Republish environment after profile change |
148| Pool autoscale not scaling up | Capacity SKU limits | Verify VCore headroom in Capacity Metrics app |
149| Table maintenance job stuck | Concurrent maintenance on same table | Wait for previous job or cancel via API |
150| Notebook cell shows no Spark Advisor | Runtime < 3.4 | Upgrade to Spark 3.4+ runtime |
151
152## References
153
154- [Microsoft Fabric Spark Compute Overview](https://learn.microsoft.com/en-us/fabric/data-engineering/spark-compute)
155- [Autotune for Apache Spark in Fabric](https://learn.microsoft.com/en-us/fabric/data-engineering/autotune)
156- [Concurrency Limits and Queueing](https://learn.microsoft.com/en-us/fabric/data-engineering/spark-job-concurrency-and-queueing)
157- [Spark Monitoring Overview](https://learn.microsoft.com/en-us/fabric/data-engineering/spark-monitoring-overview)
158- [Delta Lake Table Optimization and V-Order](https://learn.microsoft.com/en-us/fabric/data-engineering/delta-optimization-and-v-order)
159- [Resource Profile Configurations](https://learn.microsoft.com/en-us/fabric/data-engineering/resource-profile-configurations)