Review Databricks Azure node allocation

Match Databricks Azure spot VM use and on-demand fallback to the workload’s tolerance for interruption.

Description

Azure Databricks can use spot VMs after the nodes reserved by first_on_demand. Spot VMs can lower costs, but Azure may reclaim them.

Potential impact

Reclamation can interrupt scheduled work or delay recovery on a shared cluster. Retries and on-demand capacity can add cost.

Remediation

Use on-demand nodes when interruption is unacceptable. To use spot workers, consider SPOT_WITH_FALLBACK_AZURE and reserve the driver and any required nodes with first_on_demand. Test retries and costs after reclamation. Automatic termination controls idle costs.

Examples

Both excerpts use Databricks provider v1.133.0 and keep the driver on demand with first_on_demand = 1. The data source definitions are omitted.

Before

hcl
resource "databricks_cluster" "example" {
  cluster_name            = "data"
  spark_version           = data.databricks_spark_version.latest.id
  node_type_id            = data.databricks_node_type.smallest.id
  autotermination_minutes = 20

  autoscale {
    min_workers = 1
    max_workers = 50
  }

  azure_attributes {
    availability           = "SPOT_AZURE"
    first_on_demand        = 1
  }
}

After

hcl
resource "databricks_cluster" "example" {
  cluster_name            = "Shared Autoscaling"
  spark_version           = data.databricks_spark_version.latest.id
  node_type_id            = data.databricks_node_type.smallest.id
  autotermination_minutes = 20

  autoscale {
    min_workers = 1
    max_workers = 50
  }

  azure_attributes {
    availability           = "SPOT_WITH_FALLBACK_AZURE"
    first_on_demand        = 1
  }
}

The first requests SPOT_AZURE workers. The second can obtain on-demand workers when spot capacity is unavailable. Running jobs still need a recovery plan.

References