邻近放置组Proximity placement groups

将 VM 置于单个区域可以减少实例之间的物理距离。Placing VMs in a single region reduces the physical distance between the instances.

若要让 VM 尽可能靠近,将延迟尽可能降至最低,应将 VM 部署到一个邻近放置组中。To get VMs as close as possible, achieving the lowest possible latency, you should deploy them within a proximity placement group.

邻近放置组是一种逻辑分组,用于确保 Azure 计算资源在物理上彼此靠近。A proximity placement group is a logical grouping used to make sure that Azure compute resources are physically located close to each other. 邻近放置组用于要求低延迟的工作负荷。Proximity placement groups are useful for workloads where low latency is a requirement.

  • 独立 VM 之间的低延迟。Low latency between stand-alone VMs.

  • 单个可用性集或虚拟机规模集中的 VM 之间的低延迟。Low Latency between VMs in a single availability set or a virtual machine scale set.

  • 独立 VM、多个可用性集或多个规模集中的 VM 之间的低延迟。Low latency between stand-alone VMs, VMs in multiple Availability Sets, or multiple scale sets. 单个放置组中可以有多个计算资源,形成一个多层应用程序。You can have multiple compute resources in a single placement group to bring together a multi-tiered application.

  • 多个使用不同硬件类型的应用程序之间的低延迟。Low latency between multiple application tiers using different hardware types. 例如,运行在可用性集中使用 M 系列的后端,以及在单个邻近放置组的规模集的 D 系列实例上的前端。For example, running the backend using M-series in an availability set and the front end on a D-series instance, in a scale set, in a single proximity placement group.

    邻近放置组的插图

使用邻近放置组Using Proximity Placement Groups

邻近放置组是 Azure 中的一种新资源类型。A proximity placement group is a new resource type in Azure. 在将邻近放置组用于其他资源之前,需要先创建邻近放置组。You need to create one before using it with other resources. 创建后,可将其用于虚拟机、可用性集或虚拟机规模集。Once created, it could be used with virtual machines, availability sets, or virtual machine scale sets. 创建计算资源时,可以通过提供邻近放置组 ID 来指定邻近放置组。You specify a proximity placement group when creating compute resources providing the proximity placement group ID.

还可将现有资源移入邻近放置组。You can also move an existing resource into a proximity placement group. 将资源移入邻近放置组时,应该先停止(解除分配)资产,因为可能需要将资产重新部署到区域中的另一数据中心以满足共置约束。When moving a resource into a proximity placement group, you should stop (deallocate) the asset first since it will be redeployed potentially into a different data center in the region to satisfy the colocation constraint.

对于可用性集和虚拟机规模集,应在资源级别而不是在单个虚拟机上设置邻近放置组。In the case of availability sets and virtual machine scale sets, you should set the proximity placement group at the resource level rather than the individual virtual machines.

邻近放置组是一种归置约束,而不是一种固定机制。A proximity placement group is a co-location constraint rather than a pinning mechanism. 它会与要使用它的第一个资源的部署一起固定到特定的数据中心。It is pinned to a specific data center with the deployment of the first resource to use it. 停止(解除分配)或删除使用邻近放置组的所有资源后,邻近放置组将不再固定。Once all resources using the proximity placement group have been stopped (deallocated) or deleted, it is no longer pinned. 因此,在将一个邻近放置组用于多个 VM 系列时,必须尽可能地提前在模板中指定全部所需的类型,或者按照可以提高成功部署几率的部署顺序来进行。Therefore, when using a proximity placement group with multiple VM series, it is important to specify all the required types upfront in a template when possible or follow a deployment sequence which will improve your chances for a successful deployment. 如果部署失败,请使用已失败的第一个待部署 VM 大小重新开始部署。If your deployment fails, restart the deployment with the VM size which has failed as the first size to be deployed.

使用邻近放置组时预期会发生的情况What to expect when using Proximity Placement Groups

邻近放置组提供在同一数据中心内的共置。Proximity placement groups offer co-location in the same data center. 但是,因为邻近放置组提供一个附加的部署约束,因此可能会发生分配失败。However, because proximity placement groups represent an additional deployment constraint, allocation failures can occur. 在少数用例中,使用邻近放置组时你可能会遇到分配失败:There are few use cases where you may see allocation failures when using proximity placement groups:

  • 当你请求邻近放置组中的第一个虚拟机时,会自动选择数据中心。When you ask for the first virtual machine in the proximity placement group, the data center is automatically selected. 在某些情况下,当请求另一个虚拟机 SKU 时,如果它在该数据中心内不存在,则该请求可能会失败。In some cases, a second request for a different virtual machine SKU, may fail if it doesn't exist in that data center. 在这种情况下,将返回 OverconstrainedAllocationRequest 错误 。In this case, an OverconstrainedAllocationRequest error is returned. 为了避免这种情况,请尝试更改 SKU 的部署顺序,或者使用单个 ARM 模板部署这两个资源。To avoid this, try changing the order in which you deploy your SKUs or have both resources deployed using a single ARM template.
  • 对于你在其中添加和删除 VM 实例的弹性工作负荷,在部署上施加邻近放置组约束可能会导致去满足请求时失败,进而导致 AllocationFailure 错误 。In the case of elastic workloads, where you add and remove VM instances, having a proximity placement group constraint on your deployment may result in a failure to satisfy the request resulting in AllocationFailure error.
  • 根据需要停止(解除分配)再启动 VM 是实现弹性的另一种方式。Stopping (deallocate) and starting your VMs as needed is another way to achieve elasticity. 由于停止(解除分配)VM 后不会保留容量,因此再次启动该 VM 可能会导致 AllocationFailure 错误 。Since the capacity is not kept once you stop (deallocate) a VM, starting it again may result in an AllocationFailure error.

计划内维护和邻近放置组Planned maintenance and Proximity Placement Groups

计划内维护事件(如 Azure 数据中心的硬件解除)可能会影响邻近放置组中资源的对齐情况。Planned maintenance events, like hardware decommissioning at an Azure datacenter, could potentially affect the alignment of resources in proximity placement groups. 资源可转移到其他数据中心,这会干扰与邻近放置组相关的归置和延迟预期。Resources may be moved to a different data center, disrupting the collocation and latency expectations associated with the proximity placement group.

检查对齐状态Check the alignment status

可以执行以下操作来检查邻近放置组的对齐状态。You can do the following to check the alignment status of your proximity placement groups.

  • 可以使用门户、CLI 和 PowerShell 查看邻近放置组的归置状态。Proximity placement group colocation status can be viewed using the portal, CLI, and PowerShell.

    • 使用 PowerShell 时,可以使用 Get-AzProximityPlacementGroup cmdlet 并通过包含可选参数“-ColocationStatus”来获取归置状态。When using PowerShell, co-location status can be obtained using Get-AzProximityPlacementGroup cmdlet by including the optional parameter '-ColocationStatus`.

    • 使用 CLI 时,可以使用 az ppg show 并通过包含可选参数“--include-colocation-status”来获取归置状态。When using CLI, co-location status can be obtained using az ppg show by including the optional parameter '--include-colocation-status`.

  • 对于每个邻近放置组,“归置状态”属性提供了分组资源的当前对齐状态摘要。For each proximity placement group, a colocation status property provides the current alignment status summary of the grouped resources.

    • 对齐:资源在邻近放置组的相同延迟信封内。Aligned: Resource is within the same latency envelop of the proximity placement group.

    • 未知:至少已解除分配了一个 VM 资源。Unknown: at least one of the VM resources are deallocated. 成功启动它们后,状态应返回到“对齐”。Once starting them back successfully, the status should go back to Aligned.

    • 未对齐:至少一个 VM 资源未与邻近放置组对齐。Not aligned: at least one VM resource is not aligned with the proximity placement group. 未对齐的特定资源也会在成员资格部分中单独调出The specific resources which are not aligned will also be called out separately in the membership section

  • 对于可用性集,可以在“可用性集概述”页中查看有关各个 VM 的对齐信息。For Availability Sets, you can see information about alignment of individual VMs in the the Availability Set Overview page.

  • 对于规模集,可在规模集“概述”页的“实例”选项卡中查看有关各个实例的对齐信息 。For scale sets, information about alignment of individual instances can be seen in the Instances tab of the Overview page for the scale set.

重新对齐资源Re-align resources

如果邻近放置组为 Not Aligned,则可以停止\解除分配,然后重新启动受影响的资源。If a proximity placement group is Not Aligned, you can stop\deallocate and then restart the affected resources. 如果 VM 位于可用性集或规模集中,则必须先停止\解除分配可用性集或规模集中的所有 VM,然后再重新启动它们。If the VM is in an availability set or a scale set, all VMs in the availability set or scale set must be stopped\deallocated first before restarting them.

如果由于部署约束而导致分配失败,则可能需要先停止\解除分配受影响的邻近放置组中的所有资源(包括对齐的资源),然后重新启动它们以恢复对齐。If there is an allocation failure due to deployment constraints, you may have to stop\deallocate all resources in the affected proximity placement group (including the aligned resources) first and then restart them to restore alignment.

最佳做法Best practices

  • 若要实现最低的延迟,请将邻近放置组与加速网络一起使用。For the lowest latency, use proximity placement groups together with accelerated networking. 有关详细信息,请参阅创建具有加速网络的 Linux 虚拟机创建具有加速网络的 Windows 虚拟机For more information, see Create a Linux virtual machine with Accelerated Networking or Create a Windows virtual machine with Accelerated Networking.
  • 在单个模板中部署所有 VM 大小。Deploy all VM sizes in a single template. 为了避免使用不支持所需的全部 VM SKU 和大小的硬件,请将所有应用层包括在单个模板中,以便同时部署它们。In order to avoid landing on hardware that doesn't support all the VM SKUs and sizes you require, include all of the application tiers in a single template so that they will all be deployed at the same time.
  • 如果使用 PowerShell、CLI 或 SDK 来编写部署脚本,则可能会出现分配错误 OverconstrainedAllocationRequestIf you are scripting your deployment using PowerShell, CLI or the SDK, you may get an allocation error OverconstrainedAllocationRequest. 在这种情况下,应停止/解除分配所有现有的 VM,并更改部署脚本中的顺序,从失败的 VM SKU/大小开始。In this case, you should stop/deallocate all the existing VMs, and change the sequence in the deployment script to begin with the VM SKU/sizes that failed.
  • 重复使用现有的放置组时,如果系统正在删除其中的 VM,请等待删除操作全部完成再向该组添加 VM。When reusing an existing placement group from which VMs were deleted, wait for the deletion to fully complete before adding VMs to it.

后续步骤Next steps

使用 Azure CLIPowerShell 将 VM 部署到邻近放置组Deploy a VM to a proximity placement group using the Azure CLI or PowerShell

了解如何测试网络延迟Learn how to test network latency.

了解如何优化网络吞吐量Learn how to optimize network throughput.