Databricks: Custom Cluster Policies & Instance Pools in Databricks

Perf


1. πŸ”Ή Why Policies and Pools?

  • Policies β†’ Standardize and enforce cluster configurations across your organization.
  • Instance Pools β†’ Pre-create and reuse VMs to reduce startup time for clusters.

These features are critical in enterprise Databricks deployments to enforce compliance, control costs, and improve performance.


2. Custom Cluster Policies in Databricks

πŸ“Œ What is a Cluster Policy?

  • A JSON template that defines allowed, fixed, or forbidden cluster settings.
  • Ensures users follow org standards (e.g., fixed runtime, mandatory auto-termination).

πŸ›  How to Create a Custom Policy

  1. Go to Admin Console β†’ Cluster Policies.
  2. Instead of creating from scratch, clone an existing policy (e.g., Shared Compute).
  3. Edit the JSON to override settings. Example:
{
  "autotermination_minutes": {
    "type": "fixed",
    "value": 10
  },
  "num_workers": {
    "type": "fixed",
    "value": 1
  },
  "autoscale.min_workers": {
    "type": "forbidden"
  },
  "autoscale.max_workers": {
    "type": "forbidden"
  },
  "spark_version": {
    "type": "fixed",
    "value": "15.4.x-scala2.12"
  },
  "node_type_id": {
    "type": "enum",
    "values": ["Standard_DS3_v2", "Standard_DS4_v2"],
    "defaultValue": "Standard_DS4_v2"
  }
}

πŸ”‘ Explanation:

  • Auto termination β†’ Always 10 minutes.
  • Fixed workers β†’ No autoscaling allowed.
  • Fixed runtime β†’ Spark 15.4 only.
  • Restricted VM types β†’ Only Standard_DS3_v2 or DS4_v2 allowed.

πŸ“Œ How to Apply Policy to New Clusters

  • When creating a cluster, select Policy β†’ Custom Policy Name.
  • UI will grey out forbidden fields (e.g., Spark version, node type).

πŸ“Œ Enforcing Policy on Existing Clusters

  • If policy changes (e.g., Spark version updated), old clusters show β€œNon-compliant”.
  • Click Fix All β†’ Databricks auto-updates them to comply.
  • Example: Changing Spark version from 14.3 β†’ 15.4 updates all linked clusters.

βœ… This ensures org-wide compliance instantly.


3. Instance Pools in Databricks

πŸ“Œ What is an Instance Pool?

  • A predefined set of VMs ready to be attached to clusters.
  • Benefit β†’ Reduce startup time (clusters don’t need to wait for VM provisioning).
  • Clusters draw workers from the pool instead of requesting fresh VMs.

πŸ›  How to Create an Instance Pool

  1. Go to Compute β†’ Instance Pools β†’ Create Pool.
  2. Configure:
    • Min Idle Instances β†’ Always running. Keeps pool β€œwarm.”
      • Example: 2 = always 2 ready VMs.
    • Max Capacity β†’ Upper limit of VMs in the pool.
      • Example: 10 = pool can scale up to 10 nodes.
    • Idle Auto Termination β†’ Time (mins) after which unused VMs shut down.
    • Node Type β†’ VM family (e.g., DS4_v2).
    • Databricks Runtime (DBR) β†’ Pre-load runtime for faster attach.

πŸ“Œ Warm vs Cold Pools

  • Warm Pool β†’ Min Idle > 0 (e.g., 2 VMs always running).
    • βœ… Fast startup (sub-second).
    • ❌ Higher cost (pay for idle VMs).
  • Cold Pool β†’ Min Idle = 0.
    • βœ… Cost-efficient (no idle VMs).
    • ❌ Slower startup (still need to spin up VMs).

Example: Warm Instance Pool

Name: demo-pool
Min Idle Instances: 1
Max Capacity: 10
Idle Auto Termination: 10 mins
Node Type: Standard_DS4_v2
Runtime: 15.4 LTS
  • At least 1 VM always running.
  • Jobs launch instantly by borrowing warm node.
  • Released nodes wait 10 mins before termination β†’ reused if another job comes.

4. Best Practices

βœ… Use Custom Policies to:

  • Enforce auto-termination (prevent zombie clusters).
  • Fix runtime versions (e.g., always LTS).
  • Restrict node types to control cost.
  • Disable autoscaling if not needed.

βœ… Use Warm Pools for:

  • Low-latency SLA jobs (e.g., real-time ETL, streaming, dashboards).

βœ… Use Cold Pools for:

  • Batch jobs that can tolerate 2–5 min startup delay.

5. Key Differences: Policy vs Pool

FeatureCluster Policy 🚦Instance Pool 🏊
PurposeEnforce rulesReduce startup time
ControlsRuntime, nodes, auto-terminationVM availability
Cost ImpactAvoids misuseMay add idle VM costs
GovernanceCompliance toolPerformance tool

βœ… Conclusion:

  • Use Policies for governance and cost control.
  • Use Pools to optimize SLA and startup latency.
  • Combine both: Policy + Pool-backed clusters = controlled + fast compute.

Related Posts

Master Data Transformations with dbt in Modern DataOps Pipelines

Every data team knows the pain of messy SQL scripts scattered across random folders. When a pipeline breaks at midnight, you waste hours tracking down which view…

Read More

Motorcycle Road Trip China Through Mountain Landscapes and Historic Towns

Introduction China is one of the largest countries on Earth. Its road network stretches over five million kilometers. You can ride past rice terraces, deserts, snow peaks,…

Read More

Rent a Motorcycle in Canada for Independent Travel Across Provinces

Introduction Canada is the second-largest country on Earth. Its roads cross pine forests, prairie flats, and jagged mountain vistas. The Trans-Canada Highway alone stretches over 7,800 km…

Read More

Motorcycle Rental Colombia: A Simple Guide for Travelers

Introduction Traveling by road in Colombia is a great way to see the country. You can visit big cities, small towns, and beautiful mountains. Buses go to…

Read More

Warning Signs Your Gut Needs a Gastroenterologist

Your stomach hurts. You feel bloated. You are tired all the time. Does this sound like you? Millions of people face stomach, liver, and bowel problems every…

Read More

How Dagster Brings Order to Your Data Chaos

Introduction Companies today are gathering mountains of data. Every time a customer clicks a button, buys a shirt, or signs up for an email list, a new…

Read More