Sub topic 5
What a cluster costs: DBUs and infrastructure
This chapter assumes you know the driver and worker layout of a cluster, what a Spark task slot is, and the difference between on-demand and spot instances in a cloud provider. It covers how a cluster's bill is built, so that later sizing choices can be judged by cost.
Two bills, not one
A running Databricks cluster produces two separate charges:
- DBU charges. A Databricks Unit (DBU) is a unit of processing capability billed per hour of use. Databricks charges you for the DBUs your nodes consume.
- Cloud infrastructure charges. Your cloud provider bills you for the virtual machines, attached storage, and networking that the cluster uses.
Databricks sends you the first bill. The cloud provider sends you the second. Many teams only watch one of them and are surprised by the other.
How DBUs are calculated
Each node type consumes DBUs at a fixed hourly rate. Larger instances consume more DBUs per hour. The dollar price of a DBU depends on the compute type (for example, jobs compute is cheaper than all-purpose compute), your plan tier, and your contract. Check the current rate for your account instead of assuming one.
A simple model for the DBU part of the bill:
DBU cost per hour = (driver DBU rate + sum of worker DBU rates) x price per DBUThe infrastructure part follows the same shape:
Infrastructure cost per hour = sum of instance prices for the driver and all workersBoth parts scale with node count and run for as long as the cluster is up. Photon-enabled runtimes consume DBUs at a higher rate, so Photon pays off only when the job finishes enough faster to offset it.
A worked example
Suppose a cluster has one driver and four workers, all of one instance type. Assume the instance type uses 1.5 DBU per hour, a DBU costs $0.30, and the VM costs $0.31 per hour. These numbers are illustrative only.
nodes = 1 + 4 # driver plus workers
dbu_per_node_hour = 1.5
price_per_dbu = 0.30
vm_price_per_hour = 0.31
dbu_cost = nodes * dbu_per_node_hour * price_per_dbu
infra_cost = nodes * vm_price_per_hour
total = dbu_cost + infra_cost
print(f"DBU cost per hour: ${dbu_cost:.2f}")
print(f"Infra cost per hour: ${infra_cost:.2f}")
print(f"Total per hour: ${total:.2f}")This prints $2.25 for DBUs, $1.55 for infrastructure, and $3.80 in total. If the cluster sits idle for 10 hours over a weekend, that is $38.00 spent on no work. Idle time is the cost you control most easily.
Where the levers are
Spot instances lower only the infrastructure part. They do not reduce the DBU rate. Auto-termination and right-sizing reduce both, because both charges accrue per node per hour.
Exercise
Exercise
A cluster has one driver and 7 workers, all using 2 DBU per hour. A DBU costs $0.40 and each VM costs $0.50 per hour. What is the hourly total, and which part of the bill do spot instances on the workers reduce?
Show answer
There are 8 nodes. DBU cost is 8 x 2 x 0.40 = $6.40 per hour. Infrastructure cost is 8 x 0.50 = $4.00 per hour. The total is $10.40 per hour. Spot instances on the workers reduce only the infrastructure part, and only for the 7 worker nodes, so the DBU charge stays at $6.40.