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
- Go to Admin Console β Cluster Policies.
- Instead of creating from scratch, clone an existing policy (e.g.,
Shared Compute
). - 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
- Go to Compute β Instance Pools β Create Pool.
- Configure:
- Min Idle Instances β Always running. Keeps pool βwarm.β
- Example:
2
= always 2 ready VMs.
- Example:
- Max Capacity β Upper limit of VMs in the pool.
- Example:
10
= pool can scale up to 10 nodes.
- Example:
- 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.
- Min Idle Instances β Always running. Keeps pool βwarm.β
π 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
Feature | Cluster Policy π¦ | Instance Pool π |
---|---|---|
Purpose | Enforce rules | Reduce startup time |
Controls | Runtime, nodes, auto-termination | VM availability |
Cost Impact | Avoids misuse | May add idle VM costs |
Governance | Compliance tool | Performance 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.