Skip to content

Tuning Spark jobs and notebooks when they stall or run out of resources

Troubleshooting Spark jobs in Azure Databricks means diagnosing failures and slowness using the Spark UI, driver/executor logs, and cluster metrics, then applying fixes such as repartitioning, caching, or resizing clusters. Common root causes are data skew, spill to disk, small-file problems, and misconfigured executor/driver memory, all of which show up as long stages, high GC time, or shuffle-heavy plans in the Spark UI.

1 · Learn the must-know

  • The Spark UI's Stages and SQL tabs reveal skewed tasks (a few tasks taking far longer than others), excessive shuffle read/write, and spill to disk, which are the top causes of slow jobs.
  • Driver OOM errors often come from collect(), toPandas(), or broadcasting oversized tables, while executor OOM errors point to data skew or under-provisioned executor memory relative to partition size.
  • Restarting a cluster clears cached data, temp views, and widget/notebook state, and is a valid fix for stuck jobs, corrupted metastore connections, library conflicts, or after changing cluster-scoped init scripts/libraries.
  • Autoscaling and cluster sizing issues (too few workers, undersized instance types, or spot/preemption evictions) manifest as jobs that never speed up despite more data or as sporadic task failures needing driver logs to confirm.
  • Small-file problems (many tiny files from frequent writes/streaming) slow reads and should be addressed with OPTIMIZE/compaction on Delta tables rather than just scaling the cluster.
  • Repartition/coalesce, broadcast joins for small dimension tables, and adjusting shuffle partitions (spark.sql.shuffle.partitions) are standard tuning levers, but must be validated against the Spark UI rather than applied blindly.

2 · Check your understanding

Check this objectiveFree · always available

A data engineer reviews the Spark UI for a stage in a Databricks job that joins two large tables. Of 200 tasks, 199 finish in under 15 seconds, but one task runs for over 30 minutes and shows a shuffle read size far larger than the others. The job is configured with Adaptive Query Execution (AQE) disabled. What is the most effective way to resolve this issue?

Your objective map0 tried · 0 answered correctly · 77 untouched

What you have tried across DP-750's objectives, not a readiness score.

Set up and configure an Azure Databricks environment15-20% of the exam0 of 13 tried
Secure and govern Unity Catalog objects15-20% of the exam0 of 12 tried
Prepare and process data30-35% of the exam0 of 28 tried
Deploy and maintain data pipelines and workloads30-35% of the exam0 of 24 tried

3 · Keep going