Sub topic 16
How usage is billed
This chapter assumes you know what clusters, SQL warehouses, and jobs are, and that you understand the split between the control plane and the compute plane. It explains where Databricks costs come from and how to read them.
Two bills, not one
Databricks charges for usage in a unit called the DBU. Your cloud provider also bills you separately for the resources that Databricks starts in your account.
- DBU (Databricks Unit) is a unit of processing capability per hour. Databricks bills you for the DBUs your compute consumes.
- Cloud infrastructure is the virtual machines, disks, and storage that your cloud provider bills you for directly.
With classic compute, which runs in your cloud account, you pay both bills. With serverless compute, Databricks runs the resources for you, and the DBU price covers the infrastructure as well.
How DBUs are calculated
Each compute resource consumes DBUs at a rate per hour. That rate depends on the instance size and on the type of compute. Your cost is roughly:
cost = DBUs per hour × hours running × price per DBUThe price per DBU depends on your plan, your cloud, and the kind of workload. Interactive all-purpose compute costs more per DBU than job compute. Because of this, a scheduled notebook is cheaper on a job cluster than on a cluster you also use for exploration.
| Compute type | Typical use | Cost behavior |
|---|---|---|
| All-purpose compute | Interactive notebooks | Higher DBU price. Billed while running, including when idle. |
| Job compute | Scheduled jobs | Lower DBU price. Exists only for the run. |
| SQL warehouse | Databricks SQL queries | Billed while running. Size sets the DBU rate. |
| Serverless | Notebooks, jobs, and SQL | Billed for usage. Infrastructure cost is included. |
What drives cost up
Most surprises come from a few causes:
- Idle clusters. A cluster that stays running with nobody using it still consumes DBUs and VM hours. Set auto-termination so it shuts down after a period of inactivity.
- The wrong compute type. Running production jobs on all-purpose compute pays the higher rate for no benefit.
- Oversized compute. More or larger workers raise the hourly rate. They help only if the workload can use them.
- Always-on warehouses. A SQL warehouse that never stops accumulates cost. Configure auto-stop here too.
Seeing your usage
Unity Catalog's system tables include billing data. If a metastore admin has enabled the billing schema, you can query usage like any other table. The next query totals DBUs by SKU over the last 30 days.
SELECT
sku_name,
SUM(usage_quantity) AS total_dbus
FROM system.billing.usage
WHERE usage_date >= date_sub(current_date(), 30)
GROUP BY sku_name
ORDER BY total_dbus DESC;The SKU name tells you which kind of compute produced the usage. That makes it easy to check whether job compute or all-purpose compute dominates your spend.
Exercise
Exercise
A nightly notebook runs for 30 minutes on an all-purpose cluster that also stays up all day for ad hoc work. Name two changes that reduce cost.
Show answer
Run the notebook as a job on job compute, which has a lower DBU price and exists only during the run. Also set auto-termination on the all-purpose cluster so it stops when idle.