Sub topic 9
Choosing jobs compute, all-purpose compute, or SQL warehouses
This chapter assumes you can read system.billing.usage (covered earlier), know what a DBU is, and have created clusters and jobs in a workspace. It shows how to pick the compute type that fits a workload, because the choice changes the DBU rate you pay.
Three compute types, three billing profiles
| Compute type | Typical use | Lifecycle | Billing behavior |
|---|---|---|---|
| Jobs compute | Scheduled or triggered pipelines, production ETL | Created for a run, terminated when the run ends | Lowest DBU rate for general-purpose Spark. Billed only while the run lasts. |
| All-purpose compute | Interactive notebooks, exploration, development | Started by a person, stays up until it is terminated | Higher DBU rate. Billed the whole time it is running, including idle time. |
| SQL warehouse | BI dashboards, SQL queries, ad hoc analysis | Starts on demand, stops after an idle period | Billed by warehouse size and uptime. Pro and serverless types have different rates. |
Check current rates in system.billing.list_prices instead of memorizing them. They differ by cloud, SKU, and over time.
Why the same code costs different amounts
A notebook scheduled on a shared all-purpose cluster runs at the all-purpose rate. The same notebook run as a job on its own job cluster runs at the jobs rate. The cloud instance charges are identical, so the saving comes entirely from the DBU rate. The job cluster also disappears when the run finishes, so you avoid idle time.
All-purpose compute is still the right tool for development. You need a cluster that stays warm while you iterate. The cost problem appears when production work drifts onto it.
A decision path
Defining a job cluster
Declare a job cluster in the job definition so each run gets its own compute. This fragment uses the same fields as the earlier tagging chapter.
{
"job_clusters": [
{
"job_cluster_key": "etl_cluster",
"new_cluster": {
"spark_version": "15.4.x-scala2.12",
"node_type_id": "i3.xlarge",
"autoscale": { "min_workers": 2, "max_workers": 6 },
"aws_attributes": { "availability": "SPOT_WITH_FALLBACK", "first_on_demand": 1 },
"custom_tags": { "team": "data-eng", "env": "prod" }
}
}
]
}Tasks in the job refer to etl_cluster by its key. Several tasks can share one job cluster, which avoids paying start-up time for each task.
Finding misplaced workloads
Group recent usage by the product that generated it. A large all-purpose share in a workspace that should be running mostly jobs is a signal to investigate.
SELECT
billing_origin_product,
SUM(usage_quantity) AS dbus
FROM system.billing.usage
WHERE usage_date >= date_sub(current_date(), 30)
AND usage_unit = 'DBU'
GROUP BY billing_origin_product
ORDER BY dbus DESC;Typical values include JOBS, ALL_PURPOSE, and SQL. If ALL_PURPOSE dominates, drill down by usage_metadata.cluster_id or by tag to find which clusters and teams account for it.
Common mistakes
- Running scheduled jobs on a shared all-purpose cluster because it already exists. Move them to job clusters.
- Leaving all-purpose clusters without auto-termination, so a forgotten notebook bills overnight.
- Using an all-purpose cluster to serve SQL dashboards. A SQL warehouse is built for concurrent queries and stops when idle.
- Oversizing a SQL warehouse. A larger size costs more per hour. It only saves money if queries finish enough faster to offset that.
Summary
Match the workload to the compute type: SQL warehouses for SQL and BI, jobs compute for anything automated, and all-purpose compute for interactive work with auto-termination. Use the usage table to confirm that reality matches the plan.
Exercise
A nightly notebook runs on a team's shared all-purpose cluster, and the usage table shows that cluster running all day. Name two changes that reduce cost, and say which part of the bill each one reduces.
Show answer
First, move the notebook to a job with its own job cluster. This lowers the DBU rate, because jobs compute is priced below all-purpose compute. Second, make the cluster terminate when the run ends, or set a short auto-termination on the shared cluster. This removes idle hours, which lowers both DBU charges and cloud instance charges.