规模集的设计注意事项Design Considerations For Scale Sets

本文讨论虚拟机规模集的设计注意事项。This article discusses design considerations for Virtual Machine Scale Sets. 有关什么是虚拟机规模集的信息,请参阅虚拟机规模集概述For information about what Virtual Machine Scale Sets are, refer to Virtual Machine Scale Sets Overview.

何时使用规模集而不使用虚拟机?When to use scale sets instead of virtual machines?

一般而言,规模集非常适合用于部署高可用性基础结构(其中的一组计算机采用类似配置)。Generally, scale sets are useful for deploying highly available infrastructure where a set of machines has similar configuration. 但是,有些功能只能在规模集中使用,还有些功能只能在 VM 中使用。However, some features are only available in scale sets while other features are only available in VMs. 若要就何时使用每种技术做出明智的决策,我们首先应该大致了解可在规模集中使用,但不能在 VM 中使用的一些常用功能:In order to make an informed decision about when to use each technology, you should first take a look at some of the commonly used features that are available in scale sets but not VMs:

特定于规模集的功能Scale set-specific features

  • 指定规模集配置后,可以更新“容量”** 属性以并行部署更多的 VM。Once you specify the scale set configuration, you can update the capacity property to deploy more VMs in parallel. 此过程比编写一个脚本来协调众多 VM 的同时部署要简单得多。This process is better than writing a script to orchestrate deploying many individual VMs in parallel.
  • 可以使用 Azure 自动缩放来自动缩放规模集,但不能使用它来自动缩放单个 VM。You can use Azure Autoscale to automatically scale a scale set but not individual VMs.
  • 可以重置规模集 VM 的映像,但不能重置单个 VM 的映像You can reimage scale set VMs but not individual VMs.
  • 可以过度预配规模集 VM 以提高可靠性和加快部署速度。You can overprovision scale set VMs for increased reliability and quicker deployment times. 除非编写自定义代码来执行此操作,否则不能过度配置单个 VM。You cannot overprovision individual VMs unless you write custom code to perform this action.
  • 可以指定升级策略,方便在规模集中的各个 VM 上实施升级。You can specify an upgrade policy to make it easy to roll out upgrades across VMs in your scale set. 使用单个 VM 时,必须自行协调更新。With individual VMs, you must orchestrate updates yourself.

特定于 VM 的功能VM-specific features

某些功能目前仅在 VM 中可用:Some features are currently only available in VMs:

  • 可以从单个 VM 捕获映像,但不能从规模集中的 VM 捕获映像。You can capture an image from an individual VM, but not from a VM in a scale set.
  • 可将单个 VM 从本机磁盘迁移到托管磁盘,但无法迁移规模集中的 VM 实例。You can migrate an individual VM from native disks to managed disks, but you cannot migrate VM instances in a scale set.
  • 可将 IPv6 公共 IP 地址分配给单个 VM 虚拟网络接口卡 (NIC),但对于规模集中的 VM 实例,无法执行此操作。You can assign IPv6 public IP addresses to individual VM virtual network interface cards (NICs), but cannot do so for VM instances in a scale set. 可将 IPv6 公共 IP 地址分配到单个 VM 或规模集 VM 前面的负载均衡器。You can assign IPv6 public IP addresses to load balancers in front of either individual VMs or scale set VMs.

存储Storage

使用 Azure 托管磁盘创建规模集Scale sets with Azure Managed Disks

可以使用 Azure 托管磁盘而不是传统的 Azure 存储帐户创建规模集。Scale sets can be created with Azure Managed Disks instead of traditional Azure storage accounts. 托管磁盘可以提供以下优点:Managed Disks provide the following benefits:

如果存在现有的模板,则还可以将该模板更新为使用托管磁盘If you have an existing template, you can also update the template to use Managed Disks.

用户管理的存储User-managed Storage

未使用 Azure 托管磁盘定义的规模集依赖于用户创建的存储帐户在规模集中存储 VM 的 OS 磁盘。A scale set that is not defined with Azure Managed Disks relies on user-created storage accounts to store the OS disks of the VMs in the set. 建议为每个存储帐户预配不超过 20 个 VM 的比率,以实现最大 IO,并充分利用_过度预配_(请参见下文)。A ratio of 20 VMs per storage account or less is recommended to achieve maximum IO and also take advantage of overprovisioning (see below). 还建议存储帐户名称的开始部分字符采用字母表中的不同字符。It is also recommended that you spread the beginning characters of the storage account names across the alphabet. 这样做有助于在多个不同的内部系统中分散负载。Doing so helps spread load across different internal systems.

预配过度Overprovisioning

规模集当前默认为“过度预配”VM。Scale sets currently default to "overprovisioning" VMs. 开启过度预配时,规模集实际预配的 VM 数量超过所要求的数量,在成功预配所请求数量的 VM 后删除额外的 VM。With overprovisioning turned on, the scale set actually spins up more VMs than you asked for, then deletes the extra VMs once the requested number of VMs are successfully provisioned. 过度预配可提高预配成功率和减少部署时间。Overprovisioning improves provisioning success rates and reduces deployment time. 这些额外的 VM 不会计费,并且不会计入配额限制。You are not billed for the extra VMs, and they do not count toward your quota limits.

虽然过度预配可以提高预配成功率,但对于不是用于处理时而出现时而消失的额外 VM 的应用程序,会导致其行为混乱。While overprovisioning does improve provisioning success rates, it can cause confusing behavior for an application that is not designed to handle extra VMs appearing and then disappearing. 若要关闭过度预配,请确保模板中包含以下字符串:"overprovision": "false"To turn overprovisioning off, ensure you have the following string in your template: "overprovision": "false". 可在规模集 REST API 文档中找到更多详细信息。More details can be found in the Scale Set REST API documentation.

如果规模集使用用户管理的存储,并且关闭了过度预配,则可为每个存储帐户预配超过 20 个 VM,但是出于 IO 性能考虑,建议不要超过 40 个 VM。If your scale set uses user-managed storage, and you turn off overprovisioning, you can have more than 20 VMs per storage account, but it is not recommended to go above 40 for IO performance reasons.

限制Limits

在市场映像(也称为平台映像)上构建并配置为使用 Azure 托管磁盘的规模集最多支持 1,000 个 VM 的容量。A scale set built on a Marketplace image (also known as a platform image) and configured to use Azure Managed Disks supports a capacity of up to 1,000 VMs. 如果将规模集配置为支持超过 100 个 VM,则并非所有方案的运行方式都相同(例如负载均衡)。If you configure your scale set to support more than 100 VMs, not all scenarios work the same (for example load balancing). 有关详细信息,请参阅使用大型虚拟机规模集For more information, see Working with large virtual machine scale sets.

使用用户管理的存储帐户配置的规模集目前限制为 100 个 VM(建议为此规模使用 5 个存储帐户)。A scale set configured with user-managed storage accounts is currently limited to 100 VMs (and 5 storage accounts are recommended for this scale).

基于自定义映像(用户构建的映像)构建的规模集配置 Azure 托管磁盘后最多可拥有 600 个 VM 的容量。A scale set built on a custom image (one built by you) can have a capacity of up to 600 VMs when configured with Azure Managed disks. 如果规模集配置了用户管理的存储帐户,则必须在同一存储帐户中创建所有 OS 磁盘 VHD。If the scale set is configured with user-managed storage accounts, it must create all OS disk VHDs within one storage account. 因此,基于自定义映像和用户管理的存储构建的规模集中 VM 的最大建议数目为 20。As a result, the maximum recommended number of VMs in a scale set built on a custom image and user-managed storage is 20. 如果关闭预配过度,最大可为 40。If you turn off overprovisioning, you can go up to 40.

对于高出这些限制所允许的 VM,需要部署多个规模集,如此模板所示。For more VMs than these limits allow, you need to deploy multiple scale sets as shown in this template.