This topic describes how to use Alibaba Cloud ESS SDK for Java or Python to create a multi-zone scaling group.
Prerequisites
An Alibaba Cloud account is created. To create an Alibaba Cloud account, go to the account registration page.
Background information
The network type of a scaling group can be Virtual Private Cloud (VPC) or classic network. When you create a VPC-connected scaling group, you must configure a vSwitch for the scaling group. After the scaling group is created, all ECS instances that are created for the scaling group use this vSwitch.
Originally, Auto Scaling allows a VPC-connected scaling group to have only one vSwitch configured. A vSwitch belongs to only one zone. If ECS instances cannot be created in the zone where the vSwitch resides due to reasons such as insufficient resources, the scaling configurations, scaling rules, and event-triggered tasks in the scaling group become invalid.
To address the preceding issue and improve the availability of scaling groups, the VSwitchIds.N parameter is added to allow you to create multi-zone scaling groups. When you create a scaling group, you can use the VSwitchIds.N parameter to configure multiple vSwitches for the scaling group. When ECS instances cannot be created in the zone where a vSwitch resides, Auto Scaling automatically switches to the zone where a different vSwitch resides. When you use this parameter, take note of the following items:
- If the VSwitchIds.N parameter is specified, the VSwitchId parameter is ignored.
- The VSwitchIds.N parameter allows you to specify up to five vSwitches within a VPC across multiple zones when you create a scaling group. Valid values of N: 1 to 5.
- vSwitches specified in the VSwitchIds. N parameter must be within the same VPC.
- In the VSwitchIds.N parameter, N indicates the priority of each vSwitch. The vSwitch with N set to 1 has the highest priority to create ECS instances. The greater the N value, the lower the priority.
- When an ECS instance cannot be created in the zone where the vSwitch with the highest priority resides, the instance will be created in the zone where the vSwitch with the second highest priority resides. We recommend that you specify multiple vSwitches across different zones in the same region to avoid failing to create ECS instances due to insufficient resources in a single zone and improve the availability of scaling groups.