Azure Kubernetes Service (AKS) — scale-down modes — How it helps reducing cold start time?

huzefa qubbawala
6 min readApr 1, 2023

Azure Kubernetes Service (AKS) provides a managed Kubernetes cluster for easy deployment and management of containerized applications.

One of the key features of AKS is node pools, which allow you to group and manage a set of nodes together based on their characteristics, such as size, operating system, or availability zone and they can be added or removed dynamically as workload demands change. Node pools enable you to optimize your infrastructure for different workloads and use cases and to manage them independently.

In AKS, node pools can be configured with auto-scaling using different scale-down modes, which determine how nodes are removed from the pool when they are no longer needed. The two main scale-down modes are “Delete” and “Deallocate,” each with its own advantages and trade-offs.

Deallocating a node means that it is removed from the node pool, but its underlying resources (such as disks and IP addresses) are retained. This means that you can later add the node back to the node pool, and it will retain its previous configuration.

On the other hand, deleting a node means that it is permanently removed from the node pool, and its resources are released.

Delete Scale-Down Mode

If you configure the node pool with the “Delete” scale-down mode, then when the workload on the nodes decreases, AKS will automatically delete the nodes that are no longer needed until the minimum size is reached. If the workload increases again, AKS will automatically create new nodes to meet the demand.

In the “Delete” scale-down mode, nodes are completely deleted from the node pool when they are no longer needed. This means that any data, container images, and applications running on the node will be lost, and the node will need to be recreated if it is needed again.

AKS Nodepool Deleted Mode

By default, AKS creates a nodepool in delete scale-down mode -

 az aks nodepool add \
--resource-group myResourceGroup \
--cluster-name myAKSCluster \
--name nodepool1 \
--enable-cluster-autoscaler \
--min-count 1 \
--max-count 5

Deallocate Scale-Down Mode

If you configure the node pool with the “Deallocate” scale-down mode, then when the workload on the nodes decreases, AKS will deallocate the nodes that are no longer needed until the minimum size is reached. When your cluster/node pool needs to scale up, the deallocated nodes will be started first before any new nodes are provisioned.

When a node is deallocated, the container images, and node configuration, are preserved on the node, allowing for faster operation speeds if it is restarted later. Additionally, when an Azure Virtual Machine is in the Stopped (Deallocated) state, you will not be charged for the VM compute resources. You will only need to pay for any OS and data storage disks attached to the VM.

Azure VM state and Billing

Since the container images are cached inside the node, it does not have to pull the images again from the registry which significantly improves the cold start time for mission-critical applications.

AKS Nodepool Deallocated

To create a nodepool in deallocate scale-down mode, pass the scale-down mode as deallocate.

az aks nodepool add \
--resource-group myResourceGroup \
--cluster-name myAKSCluster \
--name nodepool1 \
--enable-cluster-autoscaler \
--min-count 1 \
--max-count 5 \
--scale-down-mode Deallocate

Here are some factors to consider when choosing between the “Delete” and “Deallocate” scale-down modes:

  • Statefulness: If your application requires persistent data storage and can’t tolerate losing nodes, then the “Deallocate” scale-down mode may be a better choice. If your application is stateless and can recover from node failures, then the “Delete” scale-down mode may be sufficient.
  • Cold-start time: If your application requires fast scaling and reduced cold-start times, then the “Deallocate” scale-down mode may be a better choice. If your application can tolerate longer start-up times, then the “Delete” scale-down mode may be sufficient.
  • Cost: The “Deallocate” scale-down mode may be more cost-effective in scenarios where you need to scale up and down frequently, as it allows you to save on compute costs while keeping your data intact. The “Delete” scale-down mode may be more cost-effective in scenarios where you have a stable workload and don’t need to scale up and down frequently.
  • Availability: If your workload requires high availability and can’t tolerate node failures, then the “Deallocate” scale-down mode may be a better choice, as it allows you to quickly reactivate nodes if needed. If your workload can tolerate node failures and can automatically recover from them, then the “Delete” scale-down mode may be sufficient.

Can we use Delete and Dellocate mode both ?

Yes, you can use deallocate and delete modes for different node pools within the same AKS cluster.

In AKS, you can create multiple node pools within a cluster, and each node pool can have different node sizes, configurations, and scaling settings.

AKS cluster with different scale-down modes

For example, you may have a node pool dedicated to running critical workloads that require high availability, and you may choose to deallocate nodes from this pool so that they can be quickly added back to the pool in case of a failure. On the other hand, you may have a node pool that is used for running batch jobs that have a short lifespan, and you may choose to delete nodes from this pool when they are no longer needed to free up resources. To make sure specific workloads are always running on specific node pools, taint, and toleration are used. To learn more about this, please refer to my previous article on taints and tolerations — https://medium.com/@huzefa.qubbawala/understanding-taints-tolerations-and-node-affinity-in-azure-kubernetes-services-aks-60606eb926c3

Conclusion

In conclusion, AKS node pools provide two scale-down modes — delete and deallocate — that allow you to remove nodes from a node pool and free up resources in your AKS cluster.

The delete mode permanently removes nodes from the node pool and releases all associated resources, making it ideal for situations where nodes are no longer needed or when you need to free up resources for other purposes.

The deallocate mode, on the other hand, removes nodes from the node pool but retains the associated resources, such as disks and IP addresses. This mode is useful when you want to keep the node configuration for future use or when you want to quickly add the nodes back to the node pool in case of a failure.

By choosing the appropriate scale-down mode, you can optimize the use of resources in your AKS cluster and ensure that your applications run smoothly without any interruption. The AKS scale-down modes provide a flexible and powerful way to manage your infrastructure and handle changing workload demands.

--

--

huzefa qubbawala

Senior Architect @ CTO office Icertis | Problem Solver | Cloud Solution | Azure Kubernetes | Serverless | API Management | Cognitive Service | Applied AI