If you do not require special specifications such as GPUs and local disks, we recommend that you specify the number of vCPUs and memory size instead of Elastic Compute Service (ECS) instance types to create elastic container instances. Then, the system tries to match multiple ECS instance types with the specified vCPU and memory specifications. This method provides better elasticity and resource provisioning than the method of specifying a single ECS instance type.
Specification description
You can specify the number of vCPUs and memory size for the instance or containers in the instance when you create an elastic container instance. If the number of vCPUs or memory size that you specify is not supported by Elastic Container Instance, the system adjusts the number or size based on the specifications supported by Elastic Container Instance. When the system adjusts the number or size, the system selects the most similar specifications supported by Elastic Container Instance to create the instance, and the specifications selected by the system are higher than or equal to the specifications that you specified for the instance. For example, if you specify 7 vCPUs and 13 GiB of memory when you create an elastic container instance in the China (Hangzhou) region, the system creates an instance that contains 8 vCPUs and 14 GiB of memory.
The following tables describe the specifications supported by Elastic Container Instance.
If you do not specify the number of vCPUs and memory size, the system uses 2 vCPUs and 4 GiB of memory to create an elastic container instance by default.
Each elastic container instance can have only one elastic network interface (ENI) bound.
The default temporary storage space for all specifications is 30 GiB in size.
Specify the number of vCPUs and memory size for containers in an elastic container instance
You can create a maximum of 20 containers within each elastic container instance and specify the vCPU and memory specifications of each container. For each elastic container instance, the total vCPU and memory specifications of all containers must be lower than or equal to the vCPU and memory specifications of the instance. If the total vCPU or memory specifications of all containers are higher than the vCPU or memory specifications of the instance, the system adjusts the container specifications and then charges you based on the new specifications.
Elastic Container Instance allows you to set environment variables for a specific container, such as a sidecar container, to ignore the container when the system adjusts resources. This prevents waste of resources. For more information, see Ignore specific containers when the system adjusts the specifications for an elastic container instance.
OpenAPI
When you call the CreateContainerGroup API operation to create an elastic container instance, you can use the Container.N.Cpu and Container.N.Memory parameters to specify the number of vCPUs and memory size for each container. The following table describes these parameters. For more information, see CreateContainerGroup.
Parameter | Type | Example | Description |
Container.N.Cpu | number | 2 | The number of vCPUs that you want to allocate to container N. N specifies the serial number of the container. Maximum value of N: 20. |
Container.N.Memory | number | 4 | The memory size that you want to allocate to container N. Unit: GiB N specifies the serial number of the container. Maximum value of N: 20. |
Console mode
When you create an elastic container instance in the Elastic Container Instance console, you can configure the number of vCPUs and memory size of each container in the Advanced Settings section for the container. The sum of vCPUs and sum of memory size of all containers in an elastic container instance must be smaller than or equal to the vCPU and memory size of the instance.
Specify the number of vCPUs and memory size for an elastic container instance
When this method is used, the system tries a variety of ECS instance types based on the specified number of vCPUs and memory size to select a suitable ECS instance type for better elasticity and resource provisioning. This method provides the following benefits:
You do not need to specify the number of vCPUs, memory size, or resource limits for containers in the elastic container instance. This provides the containers with greater flexibility to share the requested resources.
In genetic computation and Istio scenarios, the service framework automatically deploys sidecar containers in pods. You can seamlessly connect Elastic Container Instance to the service framework by specifying the number of vCPUs and memory size for elastic container instances.
Some specifications cannot be configured in the Elastic Container Instance console. If you cannot select a specification that is supported by Elastic Container Instance in the console, you can use the API mode.
OpenAPI
When you call the CreateContainerGroup API operation to create an elastic container instance, you can use the Cpu and Memory parameters to specify the number of vCPUs and memory size for the elastic container instance. The following table describes these parameters. For more information, see CreateContainerGroup.
Parameter | Type | Example | Description |
Cpu | number | 2 | The number of vCPUs that you want to allocate to the instance. |
Memory | number | 4 | The memory size that you want to allocate to the instance. Unit: GiB |
Console mode
When you create an elastic container instance in the Elastic Container Instance console, you can select the number of vCPUs and memory size of the elastic container instance (container group) on the Basic Mode tab in the Container Group Configurations section.