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.
-
For information about how to create a vSwitch, see Create and manage a vSwitch.
-
For information about the regions and availability zones that support ECI, see Regions and zones.
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.
|
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.