When you create an elastic container instance, you can specify CPU and memory specifications for a single container or for pods on the instance. This topic describes how to specify resource specifications for containers or pods on an elastic container instance.
Table of contents
Specify resource specifications for containers on an elastic container instance
Specify resource specifications for pods on an elastic container instance
Specify resource specifications for containers on an elastic container instance
You can specify the CPU and memory specifications of each container. The amount of resources required by an elastic container instance refers to the total amount of resources required by all containers on the elastic container instance.
Each elastic container instance supports up to 20 containers. You can specify resource specifications for each container. The sum of resources requested by containers cannot exceed the CPU and memory upper limits of the elastic container instance.
If the sum of resources requested by containers exceeds the CPU and memory upper limits of the elastic container instance, the elastic container instance automatically adjusts the CPU and memory resources as required. You are charged resource fees based on the adjusted CPU and memory resources.
For containers that are allocated more than four vCPUs, you must strictly declare the specifications of the CPU and memory resources to avoid resource allocation adjustment and resource waste. Otherwise, an error message is returned, which indicates that the resource specifications are invalid.
The following table describes the supported CPU and memory specifications.
Number of vCPUs | Memory (GiB) | emptyDir volume (GiB) | Bandwidth (bidirectional, Gbit/s, theoretical upper limit) | Packet forwarding rate (bidirectional, Kpps, theoretical upper limit) | Number of ENI queues |
0.25 | 0.5 and 1 | 30 | 0.08 | 40 | 1 |
0.5 | 1 and 2 | 30 | 0.08 | 50 | 1 |
1 | 2, 4, and 8 | 30 | 0.1 | 50 | 1 |
2 | 1, 2, 4, 8, and 16 | 30 | 1 | 300 | 2 |
4 | 2, 4, 8, 16, and 32 | 30 | 1.5 | 500 | 2 |
8 | 4, 8, 16, 32, and 64 | 30 | 2 | 800 | 4 |
12 | 12, 24, 48, and 96 | 30 | 2.5 | 900 | 4 |
16 | 16, 32, 64, and 128 | 30 | 3 | 1000 | 4 |
24 | 24, 48, 96, and 192 | 30 | 4.5 | 1500 | 6 |
32 | 32, 64, 128, and 256 | 30 | 6 | 2000 | 8 |
52 | 96, 192, and 384 | 30 | 12.5 | 3000 | 32 |
56 | 224 | 30 | 10 | 4500 | 14 |
64 | 128, 256, and 512 | 30 | 20 | 4000 | 16 |
Examples
For a Kubernetes-native container, you can directly configure the resource request
of the container
.
When the resource request of a container differs from the resource limit of the container, the container applies for resources based on the resource limit.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
resources:
requests:
cpu: "500m"
memory: "1024Mi"
- name: busybox
image: busybox:latest
ports:
- containerPort: 80
resources:
requests:
cpu: "500m"
memory: "1024Mi"
Specify resource specifications for pods on an elastic container instance
When you specify CPU and memory specifications for pods on an elastic container instance, the instance attempts to use multiple Elastic Compute Service (ECS) instance types to meet the specification requirement. This improves the scalability and success rate of elastic container instance creation compared with using only one ECS instance type. This method provides the following benefits:
You do not need to limit resources for containers on your elastic container instance. When you specify resource specifications for containers on an elastic container instance, you do not need to configure the resource
request
orlimit
. The containers on the elastic container instance can share the requested resources to the maximum extent.In genomics computing and Istio scenarios, the service framework automatically adds sidecar containers to pods. You can seamlessly integrate the elastic container instance with the service framework by explicitly specifying the instance specifications.
Examples
When the resource request of a container differs from the resource limit of the container, the container applies for resources based on the resource limit.
You can set annotations: k8s.aliyun.com/eci-use-specs in the pod configuration to specify multiple ECS instance types and separate these ECS instance types with commas (,).
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-basic
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
annotations:
k8s.aliyun.com/eci-use-specs : "2-4Gi"
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
- name: busybox
image: busybox:latest
ports:
- containerPort: 80
resources:
limits:
cpu: "500m"
memory: "1024Mi"