Create instances across multiple availability zones

更新时间:
复制 MD 格式

When you handle burst traffic, rapidly scale your services horizontally, or launch a large number of instances for batch jobs, you may encounter instance creation failures. These failures can be caused by insufficient inventory of a specific instance type in an availability zone or the exhaustion of IP addresses in a specified vSwitch. To improve the success rate of instance creation, you can specify multiple availability zones.

Prerequisites

You must have created multiple vSwitches in different availability zones within the target VPC.

Background information

When you create an ECI instance, you can specify multiple availability zones by providing multiple vSwitches. The system randomly distributes requests across the specified availability zones to balance the load. If an availability zone has insufficient inventory, the system automatically attempts to create the instance in another specified availability zone.

The following limitations apply when you specify multiple availability zones (vSwitches):

  • All specified vSwitches must belong to the same VPC.

  • You can specify a maximum of 10 vSwitches.

Combining multiple availability zones and multiple instance types further increases the instance creation success rate.

Configuration

API

When calling the CreateContainerGroup operation to create an ECI instance, use the VSwitchId parameter to specify multiple availability zones and the ScheduleStrategy parameter to configure the scheduling policy. These parameters are described in the following table. For more information, see CreateContainerGroup.

Parameter

Type

Example

Description

VSwitchId

String

vsw-bp1xpiowfm5vo8o3c,vsw-bp1rkyjgr1xwoho6k

The vSwitch ID. To specify multiple vSwitches, provide their IDs as a comma-separated string. You can specify up to 10 IDs. For example, vsw-...,vsw-....

ScheduleStrategy

String

VSwitchOrdered

The scheduling policy for the ECI instance when multiple availability zones are configured.

  • VSwitchOrdered: Schedules the instance based on the specified order. The rules are as follows:

    1. If you want to mount a disk to the pod that you are creating, the zone of the disk must be the same as the zone of the pod. The zones that do not support the pod or disk are filtered out.

    2. The system tries to create the pod in the order of the specified vSwitches that corresponds to specific zones. If available resources in the first zone are insufficient, the system tries the second zone, and so on, until the pod is created.

  • VSwitchRandom: Schedules the instance based on an inventory-optimized policy. The rules are as follows:

    1. If you want to mount a disk to the pod that you are creating, the zone of the disk must be the same as the zone of the pod. The zones that do not support the pod or disk are filtered out.

    2. Alibaba Cloud selects a vSwitch that corresponds to a zone, in which the inventory best suits your requirements.

    3. If you specified specifications for the pod that you are creating, zones that have a reserved instance for the specified pod specifications are preferentially used to create the pod.

    4. Zones that provide higher storage performance are preferentially used to create the pod. The following early zones are less preferentially used to create the pod:

      • cn-beijing-e and cn-beijing-d

      • cn-shenzhen-a, cn-shenzhen-b, and cn-shenzhen-c

      • cn-hangzhou-b, cn-hangzhou-e, and cn-hangzhou-f

      • cn-shanghai-a and cn-shanghai-c

Note

For the highest creation success rate, combine multiple availability zones (using the VSwitchId parameter) with multiple instance types (using the InstanceType parameter).

Console

When you create an ECI instance on the ECI buy page, you can select multiple vSwitches to specify multiple availability zones. On the ECI instance configuration page, set Region to China (Beijing) and select an existing VPC. If you need public network access, you must associate a NAT Gateway with the VPC and configure SNAT rules, or enable the feature to automatically create and associate an Elastic IP Address. In the vSwitch section, select multiple vSwitches from different availability zones, such as one from Zone E and one from Zone H in the China (Beijing) region. You can select up to 10 vSwitches to improve the creation success rate.

Next steps

If your instance uses a NAT Gateway to connect to the internet, you must update your SNAT entries after specifying multiple vSwitches.

For example, if your existing SNAT entries are configured at the vSwitch level, you must add new entries for the newly added vSwitches. This ensures that ECI instances launched in the new vSwitches can access the internet.