cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Why is the default auto-termination for serverless interactive notebook compute 60 minutes?

elizeu_reis
New Contributor

We've been digging into serverless interactive compute costs in notebooks, because our internal cost monitoring (cross-referencing system.billing.usage with system.query.history) showed a large share of the spend coming from idle time rather than actual query execution. To understand why, we wanted to inspect the actual cluster configuration behind a serverless notebook session โ€” but the notebook UI doesn't expose a cluster ID anywhere for serverless, so there's no obvious way to query it via API or SDK. 

How we found the serverless cluster ID (not exposed in the UI):

The workaround: open your browser's DevTools โ†’ Network tab, attach the notebook to Serverless, and run any cell. This triggers a request to the internal notebook/{notebook_id}/command endpoint. In that request's headers, look at x-databricks-attribution-tags โ€” it's a URL-encoded JSON blob, and one of its fields (clusterId) contains the serverless cluster ID generated for that session. With that ID, you can query the cluster programmatically via the SDK:

elizeu_reis_1-1786480157179.png

import os

from databricks.sdk import WorkspaceClient
from databricks.sdk.service import compute

w = WorkspaceClient()

cluster_id = "your_serverless_cluster_id"

cluster = w.clusters.get(cluster_id)

print(cluster.autotermination_minutes)

The actual finding:

Querying the cluster this way, I see that autotermination_minutes defaults to 60 minutes โ€” the same value historically used for classic all-purpose clusters, which take several minutes to spin up (which is why it makes sense not to tear down a classic cluster too quickly).

But serverless compute has the opposite value proposition: near-instant startup, with no provisioning cost for the user to wait through. That should allow for a much more aggressive idle timeout โ€” without the "wait for the cluster to come back up" trade-off that justifies 60 minutes on classic clusters.

In practice, this generates real waste: we cross-referenced system.billing.usage with system.query.history to measure real usage vs. idle time in developer sessions, and in one specific case we found 99.7% of billed time was idle โ€” a user who ran just over 1 minute of actual commands ended up billed for a 6-hour session, because the notebook was left open without ever hitting "Terminate."

When I query interactive serverless sessions for a user directly against the billing table, I can clearly see several sessions lasting exactly 60 minutes.

elizeu_reis_2-1786480657737.png

%sql
-- 'Query generated by genie code'
WITH prices AS (
  SELECT
    sku_name,
    usage_unit,
    price_start_time,
    COALESCE(price_end_time, date_add(current_date, 1)) AS price_end_time_eff,
    pricing.default AS unit_price
  FROM system.billing.list_prices
  WHERE currency_code = 'USD'
)
SELECT
  u.usage_start_time,
  u.usage_end_time,
  ROUND(timestampdiff(SECOND, u.usage_start_time, u.usage_end_time) / 60.0, 2) AS duration_minutes,
  u.sku_name,
  ROUND(u.usage_quantity, 4) AS dbu,
  ROUND(u.usage_quantity * p.unit_price, 4) AS cost_usd,
  u.usage_metadata.notebook_id AS notebook_id,
  u.usage_metadata.notebook_path AS notebook_path
FROM system.billing.usage u
  LEFT JOIN prices p
    ON u.sku_name = p.sku_name
    AND u.usage_unit = p.usage_unit
    AND u.usage_end_time BETWEEN p.price_start_time AND p.price_end_time_eff
WHERE
  u.billing_origin_product = 'INTERACTIVE'
  AND u.identity_metadata.run_as = 'USER_EMAIL'
  AND u.usage_date = '2026-08-10'
  AND u.workspace_id IN ('WORKSPACE_ID_1', 'WORKSPACE_ID_2')
ORDER BY u.usage_start_time

So, why is the default auto-termination for serverless interactive notebook compute 60 minutes? 

6 REPLIES 6

elizeu_reis
New Contributor

Confirmed with an actual serverless session left idle until it hit the timeout on its own:

elizeu_reis_0-1786498404935.png

This INACTIVITY termination only happened because I closed the notebook and reopened it more than an hour later. When I left the notebook open (tab still active, no cells running) for over an hour, the serverless cluster did not auto-terminate after the 60-minute idle window. So the idle timeout appears to only kick in reliably when the notebook itself is closed/disconnected, not simply when there's no command execution while the notebook stays open.

Niyojit
Databricks Partner

Hi @elizeu_reis ,

You can change the Serverless Cluster timeout by going to Settings โ†’ Compute.

Iโ€™ve attached a screenshot for reference. I hope this helps!

Thanks,

Niyojit

Thanks for the suggestion! That setting is different, though. "Serverless interactive execution timeout" kills a single long-running query, not the idle session. What we're asking about is autotermination_minutes (idle-based auto-termination), which we confirmed is separate: we already have "Serverless interactive execution timeout" set to 300s in both of our workspaces, but a session we left idle still only terminated after 60 min, with termination_reason.code = INACTIVITY. We haven't found an admin control for that idle value on serverless, that's the actual gap we're flagging.

RobertMitchel
Visitor

The distinction between serverless startup time and classic cluster provisioning is a good point. If serverless can start almost immediately, a 60-minute idle period can definitely result in unnecessary usage for notebooks that are left open.

Iโ€™d be interested to know whether the 60-minute value is mainly a product-design choice for interactive workflows or whether there are technical reasons for keeping the default that high. The observation that an open notebook may remain active even when no cells are running is particularly important from a cost-management perspective.

For teams concerned about unexpected usage, it seems worthwhile to monitor system.billing.usage alongside query history and establish internal guidance for disconnecting idle notebook sessions. A shorter configurable timeout would also give administrators more control over this type of workload.

After spending time investigating usage and billing, something lightweight like rollerballer.io  can be a quick browser break.

Armanillo_RoK
New Contributor III

That's an interesting find  @elizeu_reis , let's see what DBX folks come up back with on that.

Here are my two cents re I see that autotermination_minutes defaults to 60 minutes 
 -> if one happens to be creating a personal compute (not serverless) in Databricks, the initial setting of termination of the cluster set to 4320 mins and (which equals to 3 days...what a lovely Easter egg :D!) So one needs to keep in mind to change it to something around 20 mins instead right away and once done with their work switch the cluster off best.

Commodore 64 - Ninja crush 'em all
https://youtu.be/RBvhfVGMsLQ?si=OfwbqWeygGUd_qU5

Louis_Frolio
Databricks Employee
Databricks Employee

Hi @elizeu_reis , great detective work here. Cross-referencing system.billing.usage with system.query.history is exactly the right way to separate real usage from idle burn. I did some digging, and I can confirm most of what you observed. There are two different timeouts getting tangled up in this thread, so let's pull them apart.

The control @Niyojit  pointed to (Settings > Compute > Serverless interactive execution timeout) caps how long a single statement can run before it gets cancelled. The default is 2.5 hours (9,000 seconds), admins can change it at the workspace level, and you can override it per notebook with spark.databricks.execution.timeout. It's a good guardrail against runaway queries, but it has nothing to do with idle session termination. That's why your 300 second setting had no effect on the 60 minute INACTIVITY termination. Docs here: https://docs.databricks.com/aws/en/compute/serverless/notebooks

Now, the direct answer to your question: today there is no supported user or admin control for the idle timeout on serverless notebook sessions. The platform manages the session lifecycle. The docs acknowledge that idle termination happens, but they don't publish the value or expose a knob. Your measurement of 60 minutes with termination_reason.code = INACTIVITY matches what others have seen. My colleague @Ashwin_DSA dug into the same question in a related thread, confirmed there's no setting to tune, and used the same billing table approach to verify charges: https://community.databricks.com/t5/data-engineering/serverless-notebook-idle-timeout-is-it-configur...

As for why the default sits at 60 minutes, I honestly don't know, and I haven't found a published rationale. @RobertMitchel asked whether it's a product design choice or a technical constraint, and I won't guess on the record. What I can say is that on serverless the trade-off isn't startup time, it's session state. Terminating the session tears down your REPL, and every variable, temp view, and cached DataFrame goes with it. A generous idle window has historically been the protection against that.

Which brings me to the piece that changes the math: Automated session restoration for serverless notebooks. Turn it on under Settings > Developer > Experimental features. Databricks snapshots the notebook's Python and Spark state before idle termination, and when you come back a Reconnect banner restores your variables, functions, DataFrames, and temp views. Take a gander at https://www.databricks.com/blog/seamlessly-resume-sessions-serverless-notebooks and https://docs.databricks.com/aws/en/notebooks/notebook-compute. Once losing state stops hurting, terminating early (manually or otherwise) gets a lot easier to live with.

On your second observation, that an open tab kept the session alive past 60 minutes: that matches what others have reported. Termination appears to key off the notebook being disconnected, not off command execution alone. So any internal guidance you write should say "close the tab or hit Terminate," not "just stop running cells."

One caveat on the 99.7% figure. system.billing.usage is the source of truth for what you paid, and system.query.history is good activity context, but the two tables have different purposes and granularity. The comparison is a solid estimate of time with no recorded query, not an exact idle-charge ledger. Still plenty to make your case. References: https://docs.databricks.com/aws/en/admin/system-tables/billing and https://docs.databricks.com/aws/en/admin/usage/system-tables

Here's what I'd do today:

  1. Publish internal guidance to hit Terminate (or close the notebook) when done, paired with the session restoration toggle so nobody fears losing their work.
  2. Keep the execution timeout configured as a guardrail against runaway commands, knowing it won't touch the idle issue.
  3. Keep the billing monitor you built, broken out by notebook, user, SKU, and time window. Your query is a good template for others. (@RobertMitchel made the same point about monitoring.)
  4. Raise the ask through your Databricks account team or a support ticket so the product team can track it. Include your cloud and region, workspace IDs, notebook ID and path, timestamps, SKU, and the observed termination reason. You're not the first to ask for a configurable idle value, and the honest framing is a product and documentation gap: is 60 minutes intentional, and if so, can admins get a supported way to reduce it?

Also, +1 to @Armanillo_RoK's related gotcha: classic Personal Compute defaults auto-termination to 4320 minutes (3 days), so change that one right away. Just keep in mind classic auto-termination is a different compute-management model and doesn't carry over to serverless sessions.

One small caution: the x-databricks-attribution-tags header trick pokes at an internal endpoint. Smart way to investigate, but it's an implementation detail, not a supported API contract, and it could change without notice. I wouldn't build tooling on it.

Net takeaway: your diagnosis is right. The idle timeout on serverless notebooks is fixed at the platform level today, the execution timeout is a separate control, and until a knob exists your best tools are terminate discipline, session restoration, and the billing table.

Regards, Louis