Sub topic 16
How usage is billed
This chapter explains where Databricks costs come from and how to estimate and control them. It assumes you know what clusters, SQL warehouses, and jobs are from earlier chapters, and that you understand cloud object storage and virtual machines (VMs) at a basic level.
Two bills, not one
Databricks costs usually appear in two places.
- Databricks charges. You pay for platform usage, measured in Databricks Units (DBUs).
- Cloud provider charges. For classic compute, the VMs, disks, and networking in your cloud account are billed by AWS, Azure, or Google Cloud. You also pay the cloud provider for the object storage that holds your tables.
Serverless compute changes this split. Databricks runs the compute for you, so the cloud infrastructure cost is folded into the Databricks charge. You see one bill line instead of two.
| Compute type | Databricks bills you for | Your cloud provider bills you for |
|---|---|---|
| Classic cluster or classic SQL warehouse | DBUs | VMs, disks, networking |
| Serverless compute | DBUs (infrastructure included) | Nothing for the compute itself |
| Storage for tables | Nothing | Object storage and requests |
This matches the control plane and compute plane split. With classic compute, the compute plane lives in your cloud account, so those resources show up on your cloud invoice.
What a DBU is
A DBU is a unit of processing capability per hour. It is a billing unit, not a measure of work done. You are charged for the DBUs a resource consumes while it runs, and the DBU rate depends on what is running.
The basic formula is:
Databricks cost = DBUs per hour × hours running × price per DBUThree things change the numbers:
- Instance size. Larger VMs consume more DBUs per hour. A cluster with eight workers consumes roughly eight times the worker DBUs of a one-worker cluster.
- Workload type. The same hardware has different DBU rates depending on what you run on it.
- Plan and cloud. The price per DBU depends on your pricing tier, your cloud, and your contract. Check your own account's rates instead of relying on published examples.
Workload type changes the price
Databricks prices different kinds of compute at different rates. The names vary by cloud and change over time, but the pattern is stable.
| Workload | Typical use | Relative price per DBU |
|---|---|---|
| Jobs compute | Scheduled, automated pipelines | Lowest |
| All-purpose compute | Interactive notebook work | Higher |
| SQL warehouses | BI and SQL queries | Depends on type (classic, pro, serverless) |
| Serverless | No cluster management | Higher DBU rate, with infrastructure included |
The practical consequence is that running a production pipeline on an all-purpose cluster costs more per DBU than running the same notebook as a job on job compute. This is one reason the earlier chapter on turning notebooks into jobs matters for cost, not only for reliability.
Worked estimate
Suppose a nightly job runs on a classic job cluster with one driver and four workers. Assume each VM consumes 1 DBU per hour, the job rate is $0.15 per DBU, and each VM costs $0.40 per hour in your cloud account. These numbers are invented for the example.
nodes = 5 # 1 driver + 4 workers
dbu_per_node_hour = 1.0
dbu_price = 0.15 # dollars per DBU, example value
vm_price = 0.40 # dollars per VM hour, example value
hours_per_run = 0.5
runs_per_month = 30
dbus = nodes * dbu_per_node_hour * hours_per_run * runs_per_month
databricks_cost = dbus * dbu_price
cloud_cost = nodes * vm_price * hours_per_run * runs_per_month
print(f"DBUs per month: {dbus:.1f}")
print(f"Databricks charges: ${databricks_cost:.2f}")
print(f"Cloud VM charges: ${cloud_cost:.2f}")
print(f"Total: ${databricks_cost + cloud_cost:.2f}")The output is:
DBUs per month: 75.0
Databricks charges: $11.25
Cloud VM charges: $30.00
Total: $41.25In this example the VM cost is larger than the DBU cost. That ratio depends on instance type and workload type, so do not assume it holds in your account. The point is that a complete estimate needs both parts for classic compute.
What keeps the meter running
Cost accrues for as long as compute is running, not for as long as it is doing useful work. A few behaviors follow from that.
- Idle clusters cost money. An all-purpose cluster that nobody is using still consumes DBUs and VM time until it terminates. Set auto termination so an idle cluster shuts down after a chosen number of minutes.
- Startup time counts. Classic clusters take a few minutes to start, and you pay for VMs during that period. Job clusters start for each run, so very short, frequent jobs can spend a large share of their time starting up.
- Autoscaling helps with uneven load. A cluster that scales between a minimum and maximum worker count pays for fewer workers when the load is light. It does not help if the load is steady or if the minimum is set too high.
- SQL warehouses also auto stop. A warehouse that stops after a short idle period costs less than one left running. Serverless warehouses start quickly, so short idle timeouts are practical.
- Storage is separate. Tables sit in cloud object storage whether or not any compute is running. Old Delta versions kept for time travel and files awaiting cleanup add to storage cost.
Ways to reduce cost
- Use job compute for scheduled work. Move notebooks you run on a schedule off all-purpose clusters.
- Right-size clusters. Start small, watch the Spark UI and cluster metrics, and add workers only when you see a real bottleneck.
- Set auto termination and warehouse auto stop. Use short timeouts for development.
- Share compute where it is safe. A warehouse serving many analysts is usually cheaper than one per person.
- Use serverless where it fits. It removes idle startup waits and cluster management, but compare the higher DBU rate against your actual utilization.
- Use cluster policies. Administrators can cap size, require auto termination, and restrict instance types so users cannot create expensive compute by accident.
- Tag everything. Custom tags on compute and jobs flow into billing data so you can attribute cost to teams or projects.
Spot instances (discounted VMs the cloud provider can reclaim) can lower the cloud portion for fault-tolerant jobs. They do not reduce DBU charges, and a reclaimed worker means lost work that Spark must redo.
Seeing what you actually spent
Databricks exposes usage in Unity Catalog system tables, which you can query like any other table. The billing usage table records DBU consumption with metadata such as the compute resource, SKU, and tags. A system administrator may need to enable the schema and grant you access first.
SELECT
usage_date,
sku_name,
SUM(usage_quantity) AS dbus
FROM system.billing.usage
WHERE usage_date >= date_sub(current_date(), 30)
GROUP BY usage_date, sku_name
ORDER BY usage_date, sku_name;This query shows DBUs per day per SKU for the last 30 days. To get dollars, join with the list prices table in the same schema, keeping in mind that list prices may differ from your contracted rate. For cloud charges, use your provider's cost tools and filter by the tags you applied.
Common mistakes
- Estimating only DBUs. For classic compute, the cloud invoice is a second, often larger, part.
- Comparing DBU rates across workload types as if they were equal. Compare total cost per completed job instead.
- Treating serverless as always cheaper or always dearer. It depends on how idle your classic compute would have been.
- Forgetting storage. Retained history and duplicate copies of data accumulate quietly.
- Skipping tags. Without tags, you can see the total but cannot say who caused it.
Exercise
A team runs a 20-minute pipeline every hour on an all-purpose cluster that stays on all day. Name two changes that would lower the cost, and say which part of the bill each one affects.
Show answer
First, run the pipeline as a scheduled job on job compute. This lowers the DBU rate, because jobs compute is priced below all-purpose compute, and it stops the cluster from running between runs. Second, set auto termination if the cluster must stay interactive, or let a job cluster terminate after each run. This cuts the hours of VM time (cloud bill) and DBU time (Databricks bill) spent idle. A third valid option is serverless jobs compute, which removes startup and idle management while folding infrastructure into the DBU charge.
Exercise
A classic job cluster has 1 driver and 9 workers. Each node uses 2 DBUs per hour, the DBU price is $0.20, and each VM costs $0.50 per hour. The job runs for 2 hours. What are the Databricks charge and the cloud VM charge for one run?
Show answer
There are 10 nodes. DBUs = 10 × 2 × 2 = 40, so the Databricks charge is 40 × $0.20 = $8.00. VM charge = 10 × $0.50 × 2 = $10.00. The total is $18.00 for one run.