All Products
Search
Document Center

Elastic Container Instance:Ignore specific containers when the system adjusts the specifications for an elastic container instance

Last Updated:Mar 08, 2024

When you create an elastic container instance, if the vCPU and memory specifications that you specify do not meet the specification requirements of elastic container instances, the system automatically adjusts the specifications of the instance to the nearest specifications supported by Elastic Container Instance. If the specifications after the adjustment are larger than necessary, resource waste may occur. In this case, you can configure environment variables for containers that do not affect your business, such as sidecar containers, to ignore the containers during specification adjustment. This prevents resource waste and reduces the cost of using elastic container instance.

Feature description

When you specify vCPU and memory specifications to create an elastic container instance, you can specify the vCPU and memory specifications of each container. The sums of the vCPU and memory specifications of all containers cannot be greater than the specifications of the instance. If you do not specify the vCPU and memory specifications of the elastic container instance that you create, the system uses the sums of the vCPU and memory specifications of all containers to create the instance. If the sums do not match a specification supported by Elastic Container Instance, the system automatically adjusts the sums of vCPU and memory specifications to create an instance.

资源规整2

The specifications that you specify for each container are the resource upper limits for the container. When the system creates the instance, the system dynamically adjusts the resource allocation of each container. You can configure the __ECI_RESOURCE_IGNORE__:TRUE environment variable for specific containers that do not affect the business. This way, the system ignores the containers during resource adjustment. This prevents oversized instances from being created and saves resources.

Examples:

资源规整

As shown in the preceding figures, assume that you create an elastic container instance in the China (Hangzhou) region. The instance contains three containers. Containers 1 and 2 (business containers) are each configured with 2 vCPUs and 4 GiB of memory. Container 3 (sidecar container) is configured with 0.25 vCPU and 0.5 GiB of memory. In regular cases, the system automatically adjusts the specifications of the instance to 6 vCPUs and 10 GiB of memory. However, you may not actually require 6 vCPUs and 10 GiB of memory. In this case, you can configure the _ECI_RESOURCE_IGNORE_:TRUE environment variable for the sidecar container. After you configure the environment variable, the system ignores the sidecar container and adjusts the specifications of the instance to 4 vCPUs and 8 GiB of memory.

Configuration description

If you do not configure the Cpu and Memory parameters for the instance when you call the CreateContainerGroup API operation to create an elastic container instance, you can configure the Container.N.Cpu and Container.N.Memory parameters to specify the number of vCPUs and memory size for each container. For containers that you want to ignore, you can use the Container.N.EnvironmentVar.N.Key and Container.N.EnvironmentVar.N.Value parameters to configure the __ECI_RESOURCE_IGNORE__:TRUE environment variable. The following table describes these parameters. For more information, see CreateContainerGroup.

Parameter

Type

Example

Description

Cpu

Float

Not specified

The number of vCPUs that you want to allocate to the instance.

Memory

Float

Not specified

The memory size that you want to allocate to the instance. Unit: GiB

Container.N.Cpu

Float

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

Float

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.

Container.N.EnvironmentVar.N.Key

String

__ECI_RESOURCE_IGNORE__

The name of environment variable N for container N. The first N in the parameter specifies the serial number of the container. The second N specifies the serial number of the environment variable.

Container.N.EnvironmentVar.N.Value

String

TRUE

The value of environment variable N for container N. The first N in the parameter specifies the serial number of the container. The second N specifies the serial number of the environment variable.

Note

When you create an instance in the Elastic Container Instance console, you must specify the number of vCPUs and memory size of the instance. The system does not need to adjust resources to meet the specifications supported by Elastic Container Instance.