归置Co-location

导致 VM 之间延迟的最大因素之一就是距离。One of the largest contributors to latency between VMs is simply distance.

预览版:邻近放置组Preview: 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 so 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 colocation 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.

最佳做法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

为规模集创建邻近放置组Create a proximity placement group for your scale-set.