Sub topic 3
Understanding Databricks Compute Cost and Configuration
Assume you know basic Spark terms, can read JSON, and understand cloud virtual machines. Databricks cost decisions combine platform usage with infrastructure usage.
DBUs plus cloud infrastructure
A DBU (Databricks Unit) measures Databricks processing usage. Databricks charges DBUs by workload type, compute type, and region. Classic clusters also use cloud virtual machines, which create a separate cloud-provider charge for instances, storage, and sometimes networking.
Serverless pricing packages more of the infrastructure into the serverless charge. Check your Databricks and cloud-provider pricing pages before estimating a production workload.
Controlling configuration with cluster policies
A cluster policy limits or sets allowed cluster properties. Use policies to enforce approved runtimes, instance types, access modes, worker limits, and auto-termination values. This prevents unsafe or unexpectedly expensive configurations.
Policies are especially useful when many users create all-purpose clusters. They provide guardrails, but they do not replace monitoring or workload-specific sizing.
Reducing start time with instance pools
An instance pool keeps a prepared supply of cloud instances. A cluster can borrow instances from the pool, reducing allocation and startup time. Pools can still incur cost when idle, depending on the cloud and pool settings, so use them for frequent workloads where startup delay matters.
Defining compute with APIs
The Clusters API defines an all-purpose cluster. The Jobs API can define a job cluster that exists only for a run.
{
"name": "nightly-etl",
"job_clusters": [
{
"job_cluster_key": "etl",
"new_cluster": {
"spark_version": "15.4.x-scala2.12",
"node_type_id": "i3.xlarge",
"num_workers": 2,
"data_security_mode": "USER_ISOLATION"
}
}
],
"tasks": [
{
"task_key": "ingest",
"job_cluster_key": "etl",
"notebook_task": {
"notebook_path": "/Workspace/Users/[email protected]/ingest"
}
}
]
}A serverless job task omits job_cluster_key and cluster settings when serverless jobs are enabled for the workspace.
Choosing compute and troubleshooting it
| Workload | Suitable compute | Main reason |
|---|---|---|
| Development and exploration | All-purpose | Interactive and shareable |
| Scheduled production | Job cluster or serverless job | Isolated lifecycle |
| Occasional lightweight task | Serverless | Minimal cluster management |
Monitor utilization, task duration, DBU usage, and cloud costs. Slow startup can indicate scarce instances or no suitable pool capacity. High cost with low utilization often indicates oversized workers, long idle periods, or a missing auto-termination setting. Permission errors commonly point to an incompatible access mode or Unity Catalog configuration.
Exercise
A nightly pipeline runs for 20 minutes but uses an all-purpose cluster left running all day. What should you investigate first?
Show answer
Compare a job cluster or serverless job with auto-termination. Measure DBUs, infrastructure time, and startup overhead before choosing.