Sub topic 12
Instance pools to shorten startup
This chapter covers what an instance pool is, how it changes startup and cost, and how to configure one alongside autoscaling. It assumes you know how a cluster is built from a driver and workers, how autoscaling adds and removes workers, and the difference between on-demand and spot instances. Earlier chapters covered those topics.
Why cluster startup is slow
A cluster that starts from nothing asks the cloud provider for virtual machines. The provider allocates them, boots the operating system, and Databricks installs the Spark runtime on each one. This usually takes several minutes.
The delay matters in three places:
- Short jobs. A job that runs in two minutes but waits five for a cluster spends most of its wall-clock time starting up.
- Chains of jobs. A pipeline of many small job clusters pays the startup cost once per task.
- Autoscaling. When a cluster scales up, each new worker must be requested from the provider. Scale-up is slower than the load spike that triggered it.
An instance pool addresses all three by keeping spare virtual machines ready.
What an instance pool is
An instance pool is a set of idle, ready-to-use cloud instances of one node type. A cluster attached to the pool takes its driver and workers from the pool instead of requesting them from the provider. When the cluster ends, its instances return to the pool for the next cluster to use.
Idle instances in a pool do not incur DBU charges. You still pay the cloud provider for the virtual machines while they sit idle. A pool therefore trades some infrastructure cost for faster startup.
Pool settings
A pool has a small number of settings, and each one controls a different part of the trade-off.
| Setting | Meaning | Effect |
|---|---|---|
| `node_type_id` | The one instance type the pool holds | Every attached cluster uses this type |
| `min_idle_instances` | Instances kept warm at all times | Higher values give faster starts and higher idle cost |
| `max_capacity` | Upper limit on total instances, idle plus in use | Caps spend, but can block clusters when reached |
| `idle_instance_autotermination_minutes` | How long an instance above the minimum may sit idle | Shorter values release unused capacity sooner |
| `preloaded_spark_versions` | Runtime versions installed ahead of time | Removes runtime install time from startup |
Here is a pool definition for the Instance Pools API:
{
"instance_pool_name": "etl-pool",
"node_type_id": "i3.xlarge",
"min_idle_instances": 2,
"max_capacity": 20,
"idle_instance_autotermination_minutes": 15,
"preloaded_spark_versions": ["15.4.x-scala2.12"],
"aws_attributes": {
"availability": "ON_DEMAND"
}
}The pool keeps two instances warm and never holds more than 20. Instances beyond the two warm ones are released after 15 idle minutes. Because the runtime is preloaded, clusters using 15.4.x-scala2.12 skip the install step.
Attaching a cluster to a pool
A cluster refers to the pool by its ID. It does not set node_type_id, because the pool determines the node type. This specification adapts the autoscaling cluster from earlier chapters:
{
"cluster_name": "etl-autoscale-pooled",
"spark_version": "15.4.x-scala2.12",
"instance_pool_id": "<pool-id>",
"autoscale": {
"min_workers": 2,
"max_workers": 8
},
"autotermination_minutes": 30
}Replace <pool-id> with the ID returned when you created the pool. The autoscale range and auto-termination setting work as before. The difference is where new workers come from. When the cluster scales from 2 to 6 workers, the pool supplies four instances in seconds if they are idle.
Separate pools for driver and workers
A cluster can use one pool for workers and another for the driver. Set driver_instance_pool_id for the driver. This matters when you use spot instances.
If a pool is configured with spot availability, every instance it provides is spot, including the driver. A reclaimed driver ends the whole job. A common pattern is two pools:
- A small on-demand pool for drivers.
- A larger spot pool for workers.
This reproduces the "first node on-demand, workers on spot" behavior from the spot instances chapter, using pools instead of first_on_demand.
Sizing the pool
Choose min_idle_instances from how many instances your clusters typically need at the same moment, not from the largest burst.
- Count the instances a typical cluster uses, driver plus workers at its minimum size.
- Estimate how many clusters start within the same few minutes.
- Set
min_idle_instancesto cover the common case. - Set
max_capacityto the sum of the maximum sizes of all clusters that may run at once.
Setting max_capacity too low is a common error. When the pool is full, a cluster that needs more instances cannot get them. Cluster startup can fail, or an autoscaling cluster stays at its current size. Setting it too high removes the cap on spend.
Limits and gotchas
- One node type per pool. Workloads that need different instance families need different pools.
- One availability zone. Instances in a pool come from a single zone. A cluster attached to the pool runs in that zone.
- Warm instances cost money. A
min_idle_instancesof 10 on a large instance type bills around the clock, including nights and weekends. Set it to 0 for pools used only in business hours, and accept slower first starts. - No cache survives. An instance returned to the pool has its local disk cleared. A new cluster does not inherit cached data from the previous one.
- Preloading is per version. Starting a cluster on a runtime that is not preloaded still works. It only loses the install-time saving.
- Access is controlled separately. Users need permission to attach clusters to a pool. Pools are shared resources, so one team's large cluster can use up capacity another team expected.
When a pool is worth it
A pool pays off when startup time is a large share of total run time. This is typical for frequent short jobs and for interactive clusters that restart often. It pays off less for a single nightly job that runs for hours, where five minutes of startup is a small fraction. In that case an idle min_idle_instances of 0 or no pool at all costs less.
If you are using serverless compute, you do not manage pools. Databricks keeps its own warm capacity. The serverless chapter covers that option.
Exercise
A team runs 40 short jobs each morning between 06:00 and 07:00. Each job cluster needs 1 driver and 4 workers (5 instances), and about 4 clusters run at the same time. The pool is idle the rest of the day. Suggest values for min_idle_instances and max_capacity, and describe the main cost risk of your choice.
Show answer
Four concurrent clusters need about 20 instances, so max_capacity should be at least 20, for example 24 to leave headroom. For min_idle_instances, a value near 5 to 10 covers the first burst of starts while keeping idle cost modest. Using 20 would make every start fast, but those 20 virtual machines would bill all day for a one-hour workload. The main risk is paying provider charges for warm instances outside the 06:00 to 07:00 window. A schedule that lowers min_idle_instances outside that window, or a short idle_instance_autotermination_minutes, reduces the risk.