Review Databricks GCP node allocation

Match preemptible nodes and fallback capacity in a Databricks GCP cluster to its recovery requirements.

Description

Databricks on GCP can use preemptible instances to reduce cost. Google Cloud may reclaim them while work is running.

Potential impact

Recovering a cluster or rerunning work can delay completion and increase costs.

Remediation

Choose ON_DEMAND_GCP when a job cannot tolerate preemption. To use preemptible workers with fallback, choose PREEMPTIBLE_WITH_FALLBACK_GCP and use first_on_demand with a provider version that supports it. Automatic termination controls idle costs. Test recovery and retry costs separately.

Examples

These excerpts use Databricks provider v1.133.0 and omit the data source definitions. The first sets PREEMPTIBLE_GCP without an explicit on-demand count.

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
  }

  gcp_attributes {
    availability = "PREEMPTIBLE_GCP"
    zone_id      = "AUTO"
  }
}

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
  }

  gcp_attributes {
    availability           = "PREEMPTIBLE_WITH_FALLBACK_GCP"
    zone_id                = "AUTO"
    first_on_demand        = 1
  }
}

The second keeps the driver on demand with first_on_demand = 1 and can request on-demand workers if preemptible capacity is unavailable. In both, zone_id = "AUTO" selects one zone.

References