Use proximity placement groups to reduce latency for Azure Kubernetes Service (AKS) clusters
Note
When using proximity placement groups on AKS, colocation only applies to the agent nodes. Node to node and the corresponding hosted pod to pod latency is improved. The colocation doesn't affect the placement of a cluster's control plane.
When deploying your application in Azure, you can create network latency by spreading virtual machine (VM) instances across regions or availability zones, which may impact the overall performance of your application. A proximity placement group is a logical grouping used to make sure Azure compute resources are physically located close to one another. Some applications, such as gaming, engineering simulations, and high-frequency trading (HFT) require low latency and tasks that can complete quickly. For similar high-performance computing (HPC) scenarios, consider using proximity placement groups (PPG) for your cluster's node pools.
Before you begin
This article requires Azure CLI version 2.14 or later. Run az --version
to find the version. If you need to install or upgrade, see Install Azure CLI.
Limitations
- A node pool must use Virtual Machine Scale Sets to associate a proximity placement group.
- A node pool can associate a proximity placement group at node pool create time only.
Node pools and proximity placement groups
The first resource you deploy with a proximity placement group attaches to a specific data center. Any extra resources you deploy with the same proximity placement group are colocated in the same data center. Once all resources using the proximity placement group are stopped (deallocated) or deleted, it's no longer attached.
- You can associate multiple node pools with a single proximity placement group.
- You can only associate a node pool with a single proximity placement group.
Create a new AKS cluster with a proximity placement group
Accelerated networking greatly improves networking performance of virtual machines. Ideally, use proximity placement groups with accelerated networking. By default, AKS uses accelerated networking on supported virtual machine instances, which include most Azure virtual machine with two or more vCPUs.
Create an Azure resource group using the
az group create
command.az group create --name myResourceGroup --location centralus
Create a proximity placement group using the
az ppg create
command. Make sure to note the ID value in the output.az ppg create --name myPPG --resource-group myResourceGroup --location centralus --type standard
The command produces an output similar to the following example output, which includes the ID value you need for upcoming CLI commands.
{ "availabilitySets": null, "colocationStatus": null, "id": "/subscriptions/yourSubscriptionID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myPPG", "location": "chinaeast2", "name": "myPPG", "proximityPlacementGroupType": "Standard", "resourceGroup": "myResourceGroup", "tags": {}, "type": "Microsoft.Compute/proximityPlacementGroups", "virtualMachineScaleSets": null, "virtualMachines": null }
Create an AKS cluster using the
az aks create
command and replace the myPPGResourceID value with your proximity placement group resource ID from the previous step.az aks create \ --resource-group myResourceGroup \ --name myAKSCluster \ --ppg myPPGResourceID --generate-ssh-keys
Add a proximity placement group to an existing cluster
You can add a proximity placement group to an existing cluster by creating a new node pool. You can then optionally migrate existing workloads to the new node pool and delete the original node pool.
Use the same proximity placement group that you created earlier to ensure agent nodes in both node pools in your AKS cluster are physically located in the same data center.
Create a new node pool using the
az aks nodepool add
command and replace the myPPGResourceID value with your proximity placement group resource ID.az aks nodepool add \ --resource-group myResourceGroup \ --cluster-name myAKSCluster \ --name mynodepool \ --node-count 1 \ --ppg myPPGResourceID
Clean up
Delete the Azure resource group along with its resources using the
az group delete
command.az group delete --name myResourceGroup --yes --no-wait
Next steps
Learn more about proximity placement groups.