Cost control for Databricks job clusters
The five levers that actually move a Databricks bill: job clusters over all-purpose, right-sized autoscaling, spot instances, photon where it pays, and killing idle time.
TL;DR
- Scheduled workloads on all-purpose clusters typically cost ~2x what the same work costs on job clusters — that's often the whole first win.
- Autoscaling ranges like 2–20 workers hide the real question: what does this job need? Measure, then pin.
- Spot/azure low-priority workers are fine for stateless batch; keep the driver on-demand.
- Idle time is pure waste: set
autotermination_minuteslow on anything interactive.
Lever 1 — job clusters, not all-purpose
All-purpose compute carries a higher DBU rate and tends to stay up between runs. A job cluster spins up, runs, and dies:
{
"job_clusters": [{
"job_cluster_key": "nightly_etl",
"new_cluster": {
"spark_version": "15.4.x-scala2.12",
"node_type_id": "Standard_E8ds_v5",
"num_workers": 6,
"azure_attributes": {
"availability": "SPOT_WITH_FALLBACK_AZURE",
"spot_bid_max_price": -1
}
}
}]
}Lever 2 — right-size before you autoscale
Autoscaling reacts to backlog, which means it reacts late and scales up more readily than down. For a nightly batch of known size, a fixed, measured worker count is usually cheaper and faster than 2–20 autoscaling. Keep autoscaling for spiky or unpredictable loads.
Measure with the Spark UI: if your stages show heavy spill, add memory per node before adding nodes; if CPU sits under 40%, shrink.
Lever 3 — spot with a safety net
SPOT_WITH_FALLBACK_AZURE takes the discount when capacity exists and falls back to on-demand when evicted. Rules of thumb:
- Driver always on-demand.
- Fine for idempotent batch; risky for long streaming jobs where eviction storms cause rebalancing churn.
Lever 4 — Photon where it pays
Photon raises the DBU rate but can cut wall-clock far more on SQL-heavy, scan-heavy workloads. Benchmark one representative job both ways and compare total cost, not runtime. Python UDF-heavy jobs often don't benefit.
Lever 5 — kill idle time
autotermination_minutes: 15on every interactive cluster.- Alert on all-purpose clusters running after 20:00.
- Tag clusters (
team,pipeline) and build the cost dashboard per tag — unowned cost never shrinks.
From production: gotchas and lessons
- Symptom: job cluster start adds 4–6 minutes per run. Cause: cold start is the price of ephemeral compute. Fix: use cluster pools for latency-sensitive jobs; accept it for nightly batch.
- Symptom: spot evictions mid-shuffle doubled a job's runtime.
Cause: eviction during wide shuffle forces recomputation.
Fix: decommissioning migration (
spark.decommission.enabled) and on-demand for shuffle-heavy stages.
Checklist
- No scheduled workload on all-purpose compute
- Worker counts measured, not guessed
- Spot with fallback for batch; driver on-demand
- Photon decision made on cost, not runtime
- Autotermination and cost tags everywhere
Further reading
Keep going
Delta Lake MERGE without the full-table rewrite
Why MERGE quietly rewrites far more data than it changes, and the three fixes that keep it fast: prune the target, deduplicate the source, compact after.
Why AQE coalesces shuffle partitions
Adaptive Query Execution merges tiny post-shuffle partitions at runtime, so stop hand-tuning spark.sql.shuffle.partitions for every job.
Lakeflow Connect: Managed Ingestion from Databases and SaaS Sources
What a managed connector actually runs on your behalf — the ingestion gateway, staging and pipeline — plus when a connector beats hand-rolled CDC and when it doesn't.
One practical note a week
Get new articles, problems and guides in your inbox.
Thanks! You're on the list. (Local demo — no email provider is wired up yet.)