Databricks courseLesson 3 of 13
Databricks course · Lesson 3 of 13
Databricks Compute: Serverless, Classic Clusters and SQL Warehouses
Choose the right Databricks compute: serverless, all-purpose and job clusters, SQL warehouses, access modes, Photon, policies and pools, plus how DBU cost works and how to fix failures.
On this page
Every notebook cell, job task and SQL query on Databricks runs on some kind of compute. Choosing it well decides how fast a job starts, what it is allowed to read, and most of what you pay. This lesson compares the options, explains the cost model, and covers the failures you will meet when compute goes wrong. It builds on the short compute table in workspace, jobs and lakehouse.
The three families of compute
Databricks groups compute into three families.
| Family | Who manages the machines | Starts in | Best for |
|---|---|---|---|
| Serverless (notebooks, jobs, pipelines) | Databricks, in its own cloud account | Seconds (performance-optimised mode) | Most new notebooks, jobs and pipelines |
| Classic compute (all-purpose and job clusters) | You choose the VM types, size and settings; VMs run in your cloud account | Several minutes | Workloads serverless does not support, or that need custom networking, GPUs, init scripts or specific libraries |
| SQL warehouses (serverless, pro, classic) | Databricks or your account, depending on type | Seconds for serverless | SQL: dashboards, ad hoc analysis, dbt and SQL-based ETL |
Within classic compute there are two kinds of cluster:
- An all-purpose cluster is created by a person and shared for interactive work in notebooks. It keeps running until it is stopped or reaches its auto-termination timeout.
- A job cluster is created by the scheduler for one job run and terminated when the run ends. Job compute is billed at a lower rate than all-purpose compute, so production jobs should never run on a shared all-purpose cluster.
Access modes: who the cluster runs as
Classic clusters have an access mode, which decides how users are isolated and what Unity Catalog allows.
- Standard (formerly shared): many users share the cluster safely. A layer called Lakeguard isolates each user’s code, so fine-grained controls such as row filters and column masks are enforced. Some low-level features are restricted, for example the RDD API.
- Dedicated (formerly single user): the cluster is assigned to one user or one group. It supports features that standard mode restricts, such as RDDs, some machine learning runtimes and GPU work.
Serverless compute for notebooks and jobs uses standard access mode, so code that needs dedicated mode must stay on classic compute. Legacy modes without Unity Catalog support exist in older workspaces; new work should not use them.
Serverless compute in practice
Serverless removes cluster configuration: Databricks picks instance types, scales the cluster and upgrades the runtime for you (it is versionless, always on the latest serverless release). It needs a Unity Catalog-enabled workspace and is the default when you create a job with a notebook, Python script, wheel, dbt or JAR task.
For scheduled jobs and pipelines you choose a performance mode:
- Performance-optimised (the default) starts quickly and suits interactive and time-sensitive work.
- Standard tolerates a typical start-up of four to six minutes and uses fewer DBUs, so it costs less. Nightly batch jobs with no tight deadline are the obvious candidates.
Libraries for serverless job tasks are declared in an environment (a base environment version plus your pip dependencies) rather than installed on a cluster.
What serverless does not do is as important for interviews and the exam:
| Limitation | What to do instead |
|---|---|
| No R, no Scala in notebooks, no RDD API (only Spark Connect APIs) | Use dedicated classic compute for that code |
| No Spark UI or Spark logs | Use the query profile and client-side logs |
Only availableNow (or the deprecated once) streaming triggers in notebooks and jobs |
Use a continuous-mode pipeline for always-on streaming |
| Limited DBFS access; DBFS mounts not supported | Unity Catalog volumes and external locations |
| Maven coordinates and init scripts not supported | Environments with pip packages; classic compute for the rest |
| ANSI SQL mode on by default; session time zone is UTC | Handle invalid casts explicitly; set spark.sql.session.timeZone if needed |
SQL warehouses
A SQL warehouse is compute for SQL only, sized in T-shirt sizes and scaled out by adding clusters when queries queue.
| Type | Photon | Predictive IO | Intelligent workload management | Where it runs |
|---|---|---|---|---|
| Serverless | Yes | Yes | Yes | Databricks’ account; starts in seconds |
| Pro | Yes | Yes | No | Your cloud account |
| Classic | Yes | No | No | Your cloud account |
Choose serverless unless it is not available in your region or you need the warehouse inside your own network, for example to federate queries to an on-premises database; then choose pro. Classic is entry-level and rarely the right answer for new work.
Photon is Databricks’ vectorised query engine, written in C++. It speeds up SQL and DataFrame work such as scans, joins and aggregations without code changes. It is always on in SQL warehouses and serverless, and optional (with a higher DBU rate) on classic clusters. Python UDFs and RDD code do not benefit from it.
How Databricks bills compute
Databricks charges in DBUs (Databricks units), a unit of processing per hour whose price depends on the compute type and your pricing tier.
- Classic compute: you pay DBUs to Databricks and the virtual machines to your cloud provider. Job compute has a lower DBU rate than all-purpose compute; Photon raises the rate but often finishes faster.
- Serverless: you pay DBUs only; the machines are included. There is no cost for idle start-up time, but also no control over instance types.
Cost per job is visible in the system.billing.usage system table, which can lag by up to a day:
SELECT usage_date,
sku_name,
SUM(usage_quantity) AS dbus
FROM system.billing.usage
WHERE usage_metadata.job_id = '123456789'
AND usage_date >= current_date() - INTERVAL 30 DAYS
GROUP BY ALL
ORDER BY usage_date;
Join it to system.billing.list_prices to turn DBUs into money. The usual cost levers, in rough order of impact:
- Run production on job or serverless compute, not all-purpose clusters.
- Set short auto-termination on interactive clusters.
- Use standard performance mode for batch work that can wait.
- Enable autoscaling.
- Fix the slow query before adding nodes.
Governing compute with policies and pools
- Compute policies are JSON rules that limit what people can create: allowed instance types, maximum workers, required tags, forced auto-termination, and so on. Admins give teams a policy instead of unrestricted cluster creation, which caps cost and keeps tagging consistent for chargeback.
- Instance pools keep a set of idle, ready VMs. Clusters that draw from a pool start faster because they skip VM provisioning; you pay the cloud provider for idle pool instances but not DBUs.
A small policy fragment that forces auto-termination and a cost tag looks like this:
{
"autotermination_minutes": { "type": "fixed", "value": 30 },
"custom_tags.team": { "type": "fixed", "value": "data-platform" },
"num_workers": { "type": "range", "maxValue": 8 }
}
Troubleshooting compute
Cluster fails to start. Read the event log on the compute page. Common causes are a cloud quota or capacity limit for the chosen instance type (try another type or region), or no free IP addresses in the subnet. An init script that exits with an error, or a policy that rejects the configuration, also stops the start. Serverless removes most of these, which is one reason it is the default.
Library conflicts. A job fails with ModuleNotFoundError, an import error or odd behaviour after a package upgrade. Pin versions in the environment or requirements file, and do not mix %pip install in notebooks with cluster libraries for the same package. Check that the package supports the runtime’s Python and Spark versions. On serverless, %pip installs in a notebook last only for that session.
Out of memory. Decide first whether the driver or an executor ran out.
- Driver OOM usually comes from pulling data to one machine:
collect(),toPandas(), very large broadcast joins, or huge query plans built in a loop. Keep the data distributed, write results to a table, and limit what you bring back. - Executor OOM or heavy spill usually means a few partitions are too large, often from skew. Check task sizes in the Spark UI (or the query profile on serverless), let adaptive query execution split skewed partitions, salt hot keys, or choose a memory-optimised instance type. The memory and executor tuning lesson covers the settings.
Choosing compute: a short decision guide
- Is it SQL only (dashboards, BI tools, dbt)? Use a serverless SQL warehouse.
- Is it a notebook, job or pipeline that works within serverless limits? Use serverless, in standard performance mode for batch work without a tight deadline.
- Does it need R, RDDs, GPUs, init scripts, Maven libraries or custom networking? Use a classic job cluster for production and an all-purpose cluster for development, with dedicated access mode if standard mode blocks you.
- Will many people explore data interactively on classic compute? One shared standard-mode all-purpose cluster under a policy with auto-termination.
Common mistakes
- Running scheduled jobs on an all-purpose cluster. It costs more per DBU, competes with interactive users, and fails when someone restarts the cluster.
- Scaling up instead of fixing the query. Doubling workers rarely fixes a skewed join or a full table scan.
- Forgetting auto-termination. An idle all-purpose cluster left running over a weekend is a common surprise on the bill.
- Assuming serverless runs everything. Check the limitations before migrating; RDD code, R and some streaming triggers will fail.
Interview angle
“Which compute would you use for a nightly ETL job and why?” A strong answer names serverless or a job cluster and explains why not an all-purpose cluster (cost and isolation). It then mentions the trade-off between standard and performance-optimised mode, and how you would check the cost afterwards in system.billing.usage.
Key takeaway
Default to serverless for notebooks, jobs and pipelines and a serverless SQL warehouse for SQL; drop to classic job clusters only for what serverless cannot run. Control cost with job compute, auto-termination, policies and performance modes, and read the event log, Spark UI or query profile before changing cluster size.
Progress is saved in this browser only. No account needed.

