Sub topic 17
Serverless Compute and When It Replaces Manual Sizing
This chapter assumes you know the cluster concepts from earlier in this tutorial: driver and workers, autoscaling bounds, auto-termination, spot instances, instance pools, and cluster policies. It also assumes you have run notebooks and jobs in a Databricks workspace.
What serverless compute changes
With classic compute, you choose a node type, a worker count or autoscaling range, a runtime version, and an idle timeout. Databricks then starts virtual machines in your cloud account. You pay Databricks for DBUs (Databricks Units, the platform's billing unit) and you pay your cloud provider for the instances.
With serverless compute, Databricks runs the compute in its own account and manages it for you. You do not pick node types, worker counts, spot settings, or pools. The platform keeps a warm capacity pool, so startup is typically seconds rather than minutes. It also scales the resources behind your workload up and down while the workload runs. Billing is a single usage-based charge in DBUs, with no separate cloud bill for the instances.
The availability and exact behavior of serverless vary by product, cloud, and region. Check the current Databricks documentation for your workspace before you plan around a specific feature.
Forms of serverless compute
Serverless is not one product. The common forms are listed below.
| Form | Used for | What you still control |
|---|---|---|
| Serverless SQL warehouse | SQL queries, dashboards, BI tools | A warehouse size (t-shirt size) and scaling limits |
| Serverless compute for notebooks | Interactive notebook work | Environment settings such as libraries, and in some cases a memory setting |
| Serverless compute for jobs | Scheduled and triggered jobs | Job definition, environment, and performance mode options where offered |
| Lakeflow Declarative Pipelines (formerly Delta Live Tables) on serverless | Managed ETL pipelines | Pipeline definition and whether to use serverless |
Some forms keep one sizing choice. A SQL warehouse still has a size and a minimum and maximum cluster count. The decision shifts from "which instance type and how many workers" to "how large a warehouse, and how many can run at once for concurrency."
How sizing decisions map to serverless
The table below connects the manual decisions from earlier chapters to what happens on serverless.
| Classic decision | On serverless |
|---|---|
| Node type and instance family | Chosen by Databricks |
| Fixed size or autoscaling range | Managed by Databricks (some forms expose a size or a cap) |
| Spot with on-demand fallback | Not available to you; capacity handling is internal |
| Instance pool for fast startup | Not needed; startup is fast by design |
| Auto-termination | Not needed for idle cost; you are not billed for idle compute you are not using |
| Cluster policy limits | Replaced by budget policies, usage tracking, and permissions |
| Spark configuration tuning | Mostly not available; only a limited set of Spark properties can be set |
| Runtime version | Managed by Databricks through versionless updates |
The Spark partitioning and shuffle concepts still apply. Serverless removes the cluster-level choices. It does not remove the need to write efficient queries, avoid skew, and keep file sizes reasonable.
When serverless replaces manual sizing
Serverless fits well in these situations:
- Spiky or unpredictable demand. Interactive analysis and BI dashboards often have long idle periods followed by bursts. Fast startup removes the need for always-on clusters or pools.
- Many small or short jobs. A job that runs two minutes on a cluster that takes five minutes to start spends most of its time waiting. Serverless startup removes that overhead.
- Teams without cluster expertise. If nobody owns tuning, a managed option avoids oversized and forgotten clusters.
- Concurrency on SQL. A serverless SQL warehouse adds and removes clusters as queries queue and drain, so you do not hand-tune worker counts.
When classic compute is still the better choice
Keep classic compute, and the sizing skills from this tutorial, in these situations:
- You need specific hardware. GPU workloads, particular instance families, or large-memory nodes generally require classic compute, although GPU support on serverless is expanding. Check what is currently offered.
- You need low-level Spark control. Custom Spark configurations, init scripts, custom containers, or JVM options are restricted or unavailable on serverless.
- You run steady, high-utilization workloads. A long-running job that keeps a cluster busy around the clock can cost less on well-tuned classic compute, particularly with spot workers. Serverless carries a premium for the management it provides.
- You run continuous streaming with tight control. Some streaming triggers and long-running patterns are not supported, or are limited, on serverless jobs. Verify your trigger type against the documentation.
- You have compliance or network requirements. Some security configurations tie to classic compute in your own cloud account. Serverless has its own networking controls, which you must review separately.
- You depend on libraries or features not yet supported. Check the serverless limitations list for your use case.
A cost comparison method
Do not assume either option is cheaper. Measure it. For one representative workload, collect the following:
- Classic cost per run: DBU charge plus the cloud instance charge, including driver, workers, and the time spent starting and idling.
- Serverless cost per run: the DBU charge from the billing usage data.
- Wall-clock duration for both.
Then compare cost per run and cost per month at your real schedule. Include the idle time that classic compute carries. Auto-termination reduces idle cost but does not remove it, and a pool adds its own idle instance cost.
You can query billing usage in a notebook. The following example sums DBUs by product for the last seven days using the system.billing.usage system table. It needs system tables enabled and the right permissions.
usage = spark.sql("""
SELECT
billing_origin_product,
SUM(usage_quantity) AS dbus
FROM system.billing.usage
WHERE usage_date >= date_sub(current_date(), 7)
AND usage_unit = 'DBU'
GROUP BY billing_origin_product
ORDER BY dbus DESC
""")
usage.show(truncate=False)DBU totals alone are not dollars. Different products have different rates per DBU, and classic compute adds a cloud bill. Join with the price table, or use your billing dashboards, before you decide.
Common errors
- Assuming serverless has no limits. It has quotas, supported-language limits, and unsupported features. Test your workload before migrating.
- Comparing DBUs without the cloud bill. Classic compute looks cheaper on DBUs alone, because the instance cost appears elsewhere.
- Expecting Spark tuning to carry over. Settings such as
spark.sql.shuffle.partitionsmay not be changeable. Check first. Adaptive query execution handles much of this automatically. - Skipping cost controls. Serverless scales up to meet demand, so a runaway query or a badly written loop can spend money fast. Use budget policies, usage alerts, and query timeouts where available.
- Moving everything at once. Migrate one workload, compare, and expand.
Putting it into the tuning loop
The measure-and-adjust loop from the previous chapter still applies, with different levers. On classic compute you adjust worker counts, node types, and bounds. On serverless you adjust the query or job itself: partitioning, file layout, join strategy, and scheduling. If a serverless workload is slow or expensive, use the query profile to find the cause. Typical culprits are data skew, small files, and a full scan where a filter should prune partitions.
Exercise
A nightly job runs for 6 minutes on a classic cluster that needs 5 minutes to start and sits idle for 30 minutes before auto-termination. A second job runs continuously for 20 hours a day on a tuned, spot-backed cluster at high utilization. Which workload is the stronger candidate for serverless, and what should you measure before deciding about the second?
Show answer
The nightly job is the stronger candidate, because startup and idle time make up most of its classic cost, and serverless removes both. For the second job, measure the full classic cost per day (DBUs plus cloud instances, including spot pricing) and compare it with the serverless DBU cost for the same work, along with wall-clock duration. A high-utilization, spot-backed cluster often costs less on classic compute, but only the measured comparison settles it.
Exercise
Name three classic-compute settings you manage that you generally do not manage on serverless compute.
Show answer
Any three of: node type and instance family, worker count or autoscaling range, spot and on-demand configuration, instance pools, auto-termination, runtime version, and most Spark configuration properties.