Sub topic 9
Understanding cost: DBUs plus cloud infrastructure
This chapter assumes you know what a virtual machine is, how pay-as-you-go cloud billing works, and the difference between all-purpose, job, and serverless compute from earlier chapters. By the end you should be able to estimate what a workload costs on classic compute and on serverless, and explain why two clusters with the same hardware can cost different amounts.
The two parts of a classic compute bill
When you run a classic cluster (all-purpose or job compute), you pay two separate bills to two separate parties:
- Databricks charges, measured in DBUs. A Databricks Unit (DBU) is a unit of processing capability per hour. Databricks multiplies the DBUs a cluster consumes by a dollar rate per DBU.
- Cloud provider charges. The virtual machines (VMs), attached disks, networking, and public IP addresses run in your own cloud account. AWS, Azure, or Google Cloud bills you for them directly.
The two bills add up:
total cost = (DBUs consumed × price per DBU) + cloud infrastructure costServerless compute changes this. Databricks runs the machines in its own account, so there is no separate cloud VM bill for you. The serverless DBU rate includes the infrastructure.
The Databricks side of your bill appears in the Databricks account or in your cloud marketplace invoice, depending on how you signed up. The infrastructure side appears in your cloud provider's billing console. Teams that look at only one of the two consistently underestimate cost.
How DBUs are calculated
A DBU is not a measure of time or of data volume. It is a normalized unit of compute that Databricks bills per hour (or per second of use, expressed as a fraction of an hour). The number of DBUs a cluster consumes per hour depends on:
- Instance type. Larger or more specialized VMs have a higher DBU rating per hour. Each node type has a published DBU-per-hour figure.
- Number of nodes. The driver and every worker each consume DBUs while they run.
- Photon. Photon-enabled clusters consume DBUs at a higher rate than the same cluster without Photon. The bet is that the query finishes faster, so the total is lower for suitable workloads.
The price per DBU depends on:
- Workload type (SKU). Job compute is priced lower per DBU than all-purpose compute. This is the most important pricing fact in this chapter. The same notebook run on a job cluster costs less in DBUs than the same notebook run interactively on an all-purpose cluster.
- Pricing plan (tier). Your plan and cloud determine the rate, and rates differ by region and cloud.
- Commitments. Committed-use contracts can lower the rate.
Check the current price sheet for your cloud and plan. Rates change, so this chapter uses made-up numbers.
A worked example
Suppose a cluster has one driver and two workers, all of one node type. Assume these illustrative figures:
| Item | Value |
|---|---|
| DBU rating per node | 1.0 DBU per hour |
| Nodes | 3 (1 driver + 2 workers) |
| VM price per node | $0.30 per hour |
| Job compute rate | $0.15 per DBU |
| All-purpose compute rate | $0.55 per DBU |
The cluster runs for 2 hours.
- DBUs consumed: 3 nodes × 1.0 DBU/hour × 2 hours = 6 DBUs.
- Cloud infrastructure: 3 nodes × $0.30 × 2 hours = $1.80.
| Compute type | DBU cost | Infrastructure cost | Total |
|---|---|---|---|
| Job cluster | 6 × $0.15 = $0.90 | $1.80 | $2.70 |
| All-purpose cluster | 6 × $0.55 = $3.30 | $1.80 | $5.10 |
The infrastructure cost is identical. The DBU rate is what separates them. For a scheduled pipeline, moving from all-purpose to job compute cuts the bill by nearly half in this example, with no change to the code.
What counts toward infrastructure cost
The cloud side is more than VM hours. Keep these in mind:
- VM compute. Driver and workers bill from the moment the cloud provider starts them, including the startup period before Spark is ready.
- Disks and storage. Attached volumes and, on some clouds, root disks bill separately.
- Networking. Cross-region or cross-zone data transfer and public IPs can add charges.
- Spot or preemptible instances. You can configure workers to use spot capacity (AWS Spot, Azure Spot, GCP Preemptible). The cloud rate is lower, but instances can be reclaimed. DBU charges still apply at the normal rate, so the discount applies only to the infrastructure half of the bill.
- Idle time. A running cluster costs money whether or not it executes a query.
The last item is where most waste comes from. An all-purpose cluster left running overnight pays DBUs and VM costs for hours of no work. This is why the previous chapter's auto termination and autoscaling settings are cost controls, not only convenience features.
Serverless: a single combined rate
With serverless compute, you are not billed for VMs in your account. Databricks bills only DBUs, at a rate that bundles the infrastructure and management overhead. Consequences:
- The rate per DBU is higher than for the equivalent classic SKU, because it includes the machines.
- You are billed for what you use. Serverless starts in seconds and scales with the workload, so there is little startup and idle time to pay for. The billing basis depends on the product: serverless compute for jobs and notebooks bills for the compute used while work runs.
- You have fewer cost knobs. There is no node type, spot configuration, or worker count to tune. Cost control comes from the workload itself, from budgets, and from usage monitoring.
- Your cloud bill drops for this workload, because no VMs run in your account. Compare the combined total, not the Databricks line alone.
Serverless is often cheaper in total when a workload is short, bursty, or run by people who would otherwise leave clusters running. It can be more expensive for long, steady, well-tuned jobs on discounted spot instances. The only reliable way to know is to measure both with the same workload.
Where idle time and startup time hide cost
Two clusters can run the same work and bill differently because of time outside useful work.
| Source of waste | Applies to | How to reduce it |
|---|---|---|
| Idle cluster, no queries running | All-purpose | Set a short auto termination timeout |
| Over-provisioned maximum workers | All-purpose, job | Set a realistic autoscaling maximum |
| Cluster startup (minutes) | All-purpose, job | Use instance pools, or serverless |
| Oversized node type | All-purpose, job | Check memory and CPU use, then downsize |
| Interactive rate for scheduled work | All-purpose | Move scheduled work to job compute |
Notice that a job cluster has no idle problem by design. It is created for the run and terminated when the run finishes. You still pay for its startup time, because VMs are billed while Spark boots.
Measuring actual cost
Estimates are useful for planning, but you should confirm them with real usage data.
- System tables. If system tables are enabled in your account, the table
system.billing.usagerecords usage by workspace, SKU, and tags, andsystem.billing.list_pricesholds list prices. Joining the two gives estimated spend. - Tags. Add custom tags to clusters, jobs, and pools. Tags propagate to the cloud provider's resources for classic compute, so both bills can be grouped by team or project. A cluster policy can require tags so nothing goes untagged.
- Cloud billing console. This is the only source for the infrastructure half of classic compute.
A query against the system tables looks like this:
SELECT
u.usage_date,
u.sku_name,
SUM(u.usage_quantity) AS dbus,
SUM(u.usage_quantity * p.pricing.default) AS list_cost_usd
FROM system.billing.usage AS u
JOIN system.billing.list_prices AS p
ON u.sku_name = p.sku_name
AND u.usage_start_time >= p.price_start_time
AND (p.price_end_time IS NULL OR u.usage_start_time < p.price_end_time)
WHERE u.usage_date >= date_sub(current_date(), 30)
AND u.usage_unit = 'DBU'
GROUP BY u.usage_date, u.sku_name
ORDER BY u.usage_date, u.sku_name;This gives the Databricks half at list price, grouped by SKU. It does not include cloud VM charges, and it ignores any discounts in your contract. Treat it as a close estimate for comparing options, not as an invoice.
Because the SKU name distinguishes all-purpose, job, and serverless usage, you can see at a glance how much of your spend is at the higher interactive rate.
Common mistakes
- Counting only DBUs. Comparing a classic cluster's DBU line to a serverless DBU line ignores the VM bill on the classic side.
- Counting only VMs. Looking at the cloud bill and forgetting DBUs hides the larger part of the cost on many workloads.
- Running production on all-purpose compute. The interactive DBU rate applies to every hour of a scheduled job that could run on job compute.
- Assuming spot discounts apply to the whole bill. They apply only to infrastructure.
- Assuming Photon always saves money. It raises the DBU rate. Benchmark with your own queries before enabling it everywhere.
- Forgetting the driver. The driver node bills like any other node, even when workers scale to their minimum.
Summary
Classic compute costs DBUs times a rate, plus VMs from your cloud provider. The rate depends on the SKU, and job compute is cheaper per DBU than all-purpose compute. Serverless folds infrastructure into one DBU rate and reduces idle and startup waste. Idle time, over-provisioning, and using the interactive SKU for scheduled work are the main sources of avoidable spend. Confirm estimates with system tables and tags.
Exercise
A job cluster has 1 driver and 4 workers. Each node is rated at 2 DBUs per hour and costs $0.50 per hour as a VM. The job compute rate is $0.15 per DBU and the all-purpose rate is $0.55 per DBU. The cluster runs for 3 hours. Calculate the total cost on job compute and on an all-purpose cluster, and state how much the DBU rate change alone saves.
Show answer
Nodes: 5. DBUs: 5 × 2 × 3 = 30 DBUs. Infrastructure: 5 × $0.50 × 3 = $7.50. Job compute: 30 × $0.15 = $4.50 in DBUs, so $12.00 total. All-purpose: 30 × $0.55 = $16.50 in DBUs, so $24.00 total. The saving from the rate difference alone is $12.00, since the infrastructure cost is the same in both cases.
Exercise
A teammate says, "We switched the workers to spot instances, so our whole Databricks bill dropped 70%." What is wrong with this claim, and which two data sources would you check to find the real change?
Show answer
Spot pricing lowers only the cloud infrastructure charge for the workers. DBU charges are billed at the normal rate regardless of spot use, and the driver may not be on spot at all. The real change needs both halves: the cloud provider's billing console for the VM costs, and system.billing.usage (joined with list_prices) for the DBU costs.
Exercise
A nightly pipeline runs for 20 minutes on an all-purpose cluster that stays up all day with a 4-hour auto termination setting. Name two changes that would reduce cost and explain which half of the bill each affects.
Show answer
First, run the pipeline on a job cluster or serverless job compute. This lowers the DBU rate (job SKU, or a combined serverless rate) and removes the idle hours. Second, if the all-purpose cluster must stay, shorten the auto termination timeout so it stops shortly after use. This cuts idle hours on both the DBU charge and the VM charge.