All Products
Search
Document Center

Elastic Container Instance:Ignore specific containers when the system adjusts resources

Last Updated:Jan 04, 2023

This topic describes how to configure environment variables for specific containers, such as sidecar containers, to ignore these containers when the system adjusts resources. This prevents waste of resources.

Features

When you specify the 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 meet the specification requirements of elastic container instances, the system automatically adjusts the sums of vCPU and memory specifications to create the instance.

Resource adjustment 2

The vCPU and memory specifications of each container in the instance that you create cannot be greater than the specifications that you specify for each container. When the system creates the instance, the system dynamically adjusts the resource allocation of each container and may allocate vCPU and memory resources that are smaller than the specifications that you specified. For some containers in an elastic container instance that do not affect your business, you can configure the _ECI_RESOURCE_IGNORE_:TRUE environment variable. This way, the system ignores the containers during resource adjustment. This prevents instances that have excessive specifications from being created and saves resources.

Examples:

Resource adjustment

As shown in the preceding figure, an elastic container instance contains three containers. Containers 1 and 2 (business containers) are each configured with 2 vCPUs and 4 GiB memory. Container 3 (sidecar container) is configured with 0.25 vCPU and 0.5 GiB memory. In most cases, the system automatically adjusts the specifications of the instance that you want to create to 8 vCPUs and 16 GiB memory. In actual scenarios, you may not require 8 vCPUs and 16 GiB 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 that you want to create to 4 vCPUs and 8 GiB memory.

Configurations

To allow the system to ignore specific containers when the system adjusts resources, you can configure the following environment variable for the containers:

env: 
- name: "__ECI_RESOURCE_IGNORE__"
  value: "TRUE"

Sample YAML file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
  labels:
    app: test
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      name: nginx-test
      labels:
        app: nginx
        alibabacloud.com/eci: "true" 
    spec:
      containers:
      - name: nginx1
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        resources:
          limits:
            cpu: "2000m"    
            memory: "4096Mi"   
      - name: nginx2
        image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
        resources:
          limits:
            cpu: "1000m"    
            memory: "2048Mi"   
        env: 
        - name: "__ECI_RESOURCE_IGNORE__"
          value: "TRUE"
      restartPolicy: Always

When the system creates Deployments based on the preceding YAML file, the system uses the limit configurations of the nginx1 container and ignores the limit configurations of the nginx2 container. As a result, each created pod has 2 vCPUs and 4 GiB memory.