您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

通过邻近位置组减少延迟Reduce latency with proximity placement groups

备注

在 AKS 上使用邻近位置组时,归置仅适用于代理节点。When using proximity placement groups on AKS, colocation only applies to the agent nodes. 节点到节点和对应的托管 pod 到 pod 的延迟得到改进。Node to node and the corresponding hosted pod to pod latency is improved. 归置不会影响群集的控制平面的放置。The colocation does not affect the placement of a cluster's control plane.

在 Azure 中部署应用程序时,跨区域或可用性区域 (VM) 实例分配虚拟机将产生网络延迟,这可能会影响应用程序的总体性能。When deploying your application in Azure, spreading Virtual Machine (VM) instances across regions or availability zones creates network latency, which may impact the overall performance of your application. 邻近性放置组是一种逻辑分组,用于确保 Azure 计算资源的物理位置彼此接近。A proximity placement group is a logical grouping used to make sure Azure compute resources are physically located close to each other. 有些应用程序(如游戏、工程模拟和高频交易) (HFT) 需要较低的延迟和快速完成的任务。Some applications like gaming, engineering simulations, and high-frequency trading (HFT) require low latency and tasks that complete quickly. 为实现高性能计算 (HPC) 方案,请考虑使用群集节点池 (PPG) 的 邻近性放置组For high-performance computing (HPC) scenarios such as these, consider using proximity placement groups (PPG) for your cluster's node pools.

开始之前Before you begin

本文要求运行 Azure CLI 版本2.14 或更高版本。This article requires that you are running the Azure CLI version 2.14 or later. 运行 az --version 即可查找版本。Run az --version to find the version. 如果需要进行安装或升级,请参阅安装 Azure CLIIf you need to install or upgrade, see Install Azure CLI.

限制Limitations

  • 邻近位置组最多只能映射到一个可用性区域。A proximity placement group can map to at most one availability zone.
  • 节点池必须使用虚拟机规模集来关联邻近位置组。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. 部署了相同邻近位置组的其他资源将在同一数据中心中进行定位。Additional resources deployed with the same proximity placement group are colocated in the same data center. 使用邻近位置组的所有资源停止 (释放) 或删除后,就不再附加。Once all resources using the proximity placement group have been stopped (deallocated) or deleted, it's no longer attached.

  • 许多节点池可以与单个邻近布局组相关联。Many node pools can be associated with a single proximity placement group.
  • 节点池只能与单个邻近布局组相关联。A node pool may only be associated with a single proximity placement group.

通过可用性区域配置邻近位置组Configure proximity placement groups with availability zones

备注

尽管近程布局组要求一个节点池使用最多一个可用性区域,但对于单个区域中的 Vm, 99.9% 的基准 AZURE VM SLA 仍有效。While proximity placement groups require a node pool to use at most one availability zone, the baseline Azure VM SLA of 99.9% is still in effect for VMs in a single zone.

邻近性放置组是一个节点池概念,并与每个单独的节点池相关联。Proximity placement groups are a node pool concept and associated with each individual node pool. 使用 PPG 资源对 AKS 控制面可用性没有影响。Using a PPG resource has no impact on AKS control plane availability. 这可能会影响使用区域设计群集的方式。This can impact how a cluster should be designed with zones. 若要确保群集跨多个区域分布,建议采用以下设计。To ensure a cluster is spread across multiple zones the following design is recommended.

  • 使用3个区域预配具有第一个系统池的群集,而不会对任何邻近的放置组进行关联。Provision a cluster with the first system pool using 3 zones and no proximity placement group associated. 这可确保在专用节点池中的系统箱土地分散到多个区域。This ensures the system pods land in a dedicated node pool which will spread across multiple zones.
  • 添加具有唯一区域的其他用户节点池和与每个池关联的邻近位置组。Add additional user node pools with a unique zone and proximity placement group associated to each pool. 例如,区域1中的 nodepool1、区域2中的 PPG1、nodepool2 和区域3中的 PPG2、nodepool3 和 PPG3。An example is nodepool1 in zone 1 and PPG1, nodepool2 in zone 2 and PPG2, nodepool3 in zone 3 with PPG3. 这可以确保在群集级别,节点分散到多个区域,而每个单独的节点池在指定的区域中与专用 PPG 资源协同工作。This ensures at a cluster level, nodes are spread across multiple zones and each individual node pool is colocated in the designated zone with a dedicated PPG resource.

使用邻近位置组创建新的 AKS 群集Create a new AKS cluster with a proximity placement group

以下示例使用 az group create命令在 centralus 区域中创建名为 myResourceGroup 的资源组。The following example uses the az group create command to create a resource group named myResourceGroup in the centralus region. 然后使用 az AKS create 命令创建名为 myAKSCluster 的 AKS 群集。An AKS cluster named myAKSCluster is then created using the az aks create command.

加速网络极大地提高了虚拟机的网络性能。Accelerated networking greatly improves networking performance of virtual machines. 理想情况下,将邻近组与加速网络结合使用。Ideally, use proximity placement groups in conjunction with accelerated networking. 默认情况下,AKS 使用支持的 虚拟机实例上的加速网络,其中包含具有两个或更多个 vcpu 的大多数 Azure 虚拟机。By default, AKS uses accelerated networking on supported virtual machine instances, which include most Azure virtual machine with two or more vCPUs.

使用与第一个系统节点池关联的邻近位置组创建新的 AKS 群集:Create a new AKS cluster with a proximity placement group associated to the first system node pool:

# Create an Azure resource group
az group create --name myResourceGroup --location centralus

运行以下命令,并存储返回的 ID:Run the following command, and store the ID that is returned:

# Create proximity placement group
az ppg create -n myPPG -g myResourceGroup -l centralus -t standard

此命令生成输出,其中包括即将推出的 CLI 命令所需的 id 值:The command produces 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": "centralus",
  "name": "myPPG",
  "proximityPlacementGroupType": "Standard",
  "resourceGroup": "myResourceGroup",
  "tags": {},
  "type": "Microsoft.Compute/proximityPlacementGroups",
  "virtualMachineScaleSets": null,
  "virtualMachines": null
}

在下面的命令中,使用 " myPPGResourceID " 值的邻近位置组资源 ID:Use the proximity placement group resource ID for the myPPGResourceID value in the below command:

# Create an AKS cluster that uses a proximity placement group for the initial system node pool only. The PPG has no effect on the cluster control plane.
az aks create \
    --resource-group myResourceGroup \
    --name myAKSCluster \
    --ppg myPPGResourceID

向现有群集添加邻近布局组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 then delete the original node pool.

使用之前创建的邻近位置组,这将确保 AKS 群集的两个节点池中的代理节点物理位于同一数据中心。Use the same proximity placement group that you created earlier, and this will ensure agent nodes in both node pools in your AKS cluster are physically located in the same data center.

使用前面创建的邻近位置组中的资源 ID,并使用以下命令添加新的节点池 az aks nodepool addUse the resource ID from the proximity placement group you created earlier, and add a new node pool with the az aks nodepool add command:

# Add a new node pool that uses a proximity placement group, use a --node-count = 1 for testing
az aks nodepool add \
    --resource-group myResourceGroup \
    --cluster-name myAKSCluster \
    --name mynodepool \
    --node-count 1 \
    --ppg myPPGResourceID

清理Clean up

若要删除群集,请使用 az group delete 命令删除 AKS 资源组:To delete the cluster, use the az group delete command to delete the AKS resource group:

az group delete --name myResourceGroup --yes --no-wait

后续步骤Next steps