如何在门户中为云服务配置自动缩放How to configure auto scaling for a Cloud Service in the portal

针对云服务辅助角色设置条件,以触发横向缩减或扩展操作。Conditions can be set for a cloud service worker role that trigger a scale in or out operation. 针对角色的条件可以基于 CPU、磁盘或角色的网络负载。The conditions for the role can be based on the CPU, disk, or network load of the role. 也可以基于消息队列或与订阅关联的其他一些 Azure 资源的指标来设置条件。You can also set a condition based on a message queue or the metric of some other Azure resource associated with your subscription.

备注

本文着重于云服务 Web 和辅助角色。This article focuses on Cloud Service web and worker roles. 如果直接创建虚拟机(经典),该虚拟机将托管在云服务中。When you create a virtual machine (classic) directly, it is hosted in a cloud service. 可以通过将标准虚拟机与可用性集相关联来缩放标准虚拟机,并手动将其打开或关闭。You can scale a standard virtual machine by associating it with an availability set and manually turn them on or off.

注意事项Considerations

在配置应用程序的缩放之前,应考虑以下信息:You should consider the following information before you configure scaling for your application:

  • 缩放受内核使用情况影响。Scaling is affected by core usage.

    角色实例越大,使用的内核越多。Larger role instances use more cores. 只能在订阅的内核限制内缩放应用程序。You can scale an application only within the limit of cores for your subscription. 例如,假设订阅有 20 个核心的限制。For example, say your subscription has a limit of 20 cores. 如果通过两个中等规模的云服务(一共 4 个核心)运行某个应用程序,则对于订阅中的其他云服务部署,只有 16 个核心的扩展空间。If you run an application with two medium-sized cloud services (a total of 4 cores), you can only scale up other cloud service deployments in your subscription by the remaining 16 cores. 有关大小的详细信息,请参阅云服务的大小For more information about sizes, see Cloud Service Sizes.

  • 可以基于队列消息阈值来进行缩放。You can scale based on a queue message threshold. 有关如何使用队列的详细信息,请参阅如何使用队列存储服务For more information about how to use queues, see How to use the Queue Storage Service.

  • 还可以缩放与订阅关联的其他资源。You can also scale other resources associated with your subscription.

  • 若要使应用程序具有高可用性,应确保为其部署两个或更多角色实例。To enable high availability of your application, you should ensure that it is deployed with two or more role instances. 有关详细信息,请参阅服务级别协议For more information, see Service Level Agreements.

  • 仅当所有角色都处于“就绪”状态时才能自动缩放 。Auto Scale only happens when all the roles are in Ready state.  

缩放位置Where scale is located

选择云服务之后,应会看到云服务边栏选项卡。After you select your cloud service, you should have the cloud service blade visible.

  1. 在云服务边栏选项卡上的“角色和实例” 磁贴中,选择云服务的名称。On the cloud service blade, on the Roles and Instances tile, select the name of the cloud service.
    重要说明:请务必单击云服务角色,而不是角色下面的角色实例。IMPORTANT: Make sure to click the cloud service role, not the role instance that is below the role.

    “角色和实例”磁贴的屏幕截图,其中“WorkerRoleWithSBQueue1”选项以红框标出。

  2. 选择“缩放” 磁贴。Select the scale tile.

    “操作”页的屏幕截图,其中“缩放”磁贴以红框标出。

自动缩放Automatic scale

可以使用手动自动模式来配置角色的缩放设置。You can configure scale settings for a role with either two modes manual or automatic. 顾名思义,“手动”模式可以设置实例的绝对计数。Manual is as you would expect, you set the absolute count of instances. 但是,“自动”模式可让你设置规则来控制缩放的方式和程度。Automatic however allows you to set rules that govern how and by how much you should scale.

将“缩放方式” 选项设置为“计划和性能规则”。Set the Scale by option to schedule and performance rules.

包含配置文件和规则的云服务缩放设置

  1. 现有的配置文件。An existing profile.
  2. 添加父配置文件的规则。Add a rule for the parent profile.
  3. 添加另一个配置文件。Add another profile.

选择“添加配置文件”。Select Add Profile. 配置文件确定了用于缩放的模式:始终定期固定日期The profile determines which mode you want to use for the scale: always, recurrence, fixed date.

配置了配置文件和规则之后,请选择顶部的“保存” 图标。After you have configured the profile and rules, select the Save icon at the top.

配置文件Profile

配置文件可设置缩放的实例数下限和上限,以及此缩放范围生效的时间。The profile sets minimum and maximum instances for the scale, and also when this scale range is active.

  • 始终Always

    始终使此范围的实例数保持可用。Always keep this range of instances available.

    始终缩放的云服务

  • 定期Recurrence

    选择一组要缩放的星期日期。Choose a set of days of the week to scale.

    使用定期计划的云服务缩放

  • 固定日期Fixed Date

    要缩放角色的固定日期范围。A fixed date range to scale the role.

    使用固定日期的云服务缩放

配置了配置文件之后,请选择配置文件边栏选项卡底部的“确定” 按钮。After you have configured the profile, select the OK button at the bottom of the profile blade.

规则Rule

规则将添加到配置文件,代表触发缩放的条件。Rules are added to a profile and represent a condition that triggers the scale.

规则触发器基于云服务的指标(CPU 使用量、磁盘活动或网络活动),可以在其中添加条件值。The rule trigger is based on a metric of the cloud service (CPU usage, disk activity, or network activity) to which you can add a conditional value. 此外,也可以基于消息队列或与订阅关联的其他一些 Azure 资源的指标来设置触发器。Additionally you can have the trigger based on a message queue or the metric of some other Azure resource associated with your subscription.

“规则”对话框的屏幕截图,其中“指标名称”选项以红框标出。

配置规则之后,请选择规则边栏选项卡底部的“确定” 按钮。After you have configured the rule, select the OK button at the bottom of the rule blade.

返回到手动缩放Back to manual scale

导航到 缩放设置,并将 缩放方式 选项设置为 手动输入的实例计数Navigate to the scale settings and set the Scale by option to an instance count that I enter manually.

包含配置文件和规则的云服务缩放设置

此设置会删除角色中的自动缩放,用户就可以直接设置实例计数。This setting removes automated scaling from the role and then you can set the instance count directly.

  1. 缩放(手动或自动)选项。The scale (manual or automated) option.
  2. 角色实例滑块,用于设置要缩放的实例。A role instance slider to set the instances to scale to.
  3. 要缩放的角色实例。Instances of the role to scale to.

配置缩放设置后,请选择顶部的 保存 图标。After you have configured the scale settings, select the Save icon at the top.