Sub topic 12
Instance pools to shorten startup
This chapter assumes you know how to create a cluster, what autoscaling does, and the difference between on-demand and spot instances. Here you will see how instance pools cut cluster startup time and how they affect autoscaling and cost.
Why startup time matters
A new cluster has to request virtual machines from the cloud provider, wait for them to boot, and install the Databricks runtime. This usually takes several minutes. Autoscaling pays the same price each time it adds workers. Scale-up is slow if every new worker is a cold instance request.
An instance pool is a set of idle, ready-to-use instances that Databricks keeps for you. Clusters take their nodes from the pool instead of asking the cloud provider. When a cluster ends, its instances return to the pool for the next cluster.
How a pool works
You set these options when you create a pool:
- Node type: every instance in the pool has this type. A cluster that uses the pool must use the same type.
- Min idle instances: the number of instances kept warm. They are always ready.
- Max capacity: an upper limit on all instances the pool holds, both idle and in use.
- Idle instance auto-termination: how many minutes an extra idle instance stays before it is released. Instances within the min idle count are not released.
Pools and cost
While instances sit idle in a pool, you pay the cloud provider for them. You do not pay Databricks DBUs for idle pool instances. DBUs are charged only while a cluster is running on them. A pool therefore trades a small infrastructure cost for faster startup.
Keep the min idle count low. Setting it to the number of workers you might need at peak mostly buys idle machines. A value of 0 still helps: instances that a finished cluster returns stay in the pool until the idle timeout, so the next cluster starts quickly.
Using a pool with a cluster
In the cluster specification, you replace node_type_id with a pool ID. The runtime version and autoscale range stay as before.
{
"cluster_name": "etl-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 shown on the pool's page. You can also set driver_instance_pool_id to give the driver a different pool.
Common errors
- Pool too small for the autoscale maximum. If the pool's max capacity is below what clusters ask for, they wait or fail to scale up. Set max capacity at or above the sum of the maximum sizes of all clusters sharing the pool.
- Mismatched node types. One pool holds one node type. Workloads that need a different type need another pool.
- Spot and on-demand mixed up. A pool is created as spot or on-demand. A pool of spot instances can still lose instances to reclamation.
- Forgetting the cost of idle instances. A large min idle count on a pool nobody uses keeps costing money.
Exercise
A pool has min idle instances set to 0, and a cluster that used it has just terminated. Will the next cluster that uses the pool still start faster than one with no pool? Do you pay DBUs for the instances that are sitting idle?
Show answer
Yes, it will usually start faster. The returned instances stay in the pool until the idle auto-termination timeout passes, so the next cluster can reuse them without a new cloud request. You pay the cloud provider for the idle instances, but you do not pay DBUs for them. DBUs apply only while a cluster is running.