Help Center> Cloud Container Instance> Developer Guide> Pod> Calculating the Effective Resource Request or Limit of a Pod
Updated on 2023-09-26 GMT+08:00

Calculating the Effective Resource Request or Limit of a Pod

To calculate the pod's effective resource request or limit, perform the following steps:

  1. Obtain the request or limit on each init container in the pod. The highest request or limit for a resource is the effective init request or limit for the resource.
  2. Compare the following two items. The pod's effective request or limit for a resource is the higher of the two items:

    • The sum of all application container requests or limits for the resource
    • The effective init request or limit for the resource

The following example shows how to calculate pod specifications.

apiVersion: v1
kind: Pod
metadata:
  name: web-app
spec:
  initContainers:
  - name: config-generator
    image: busybox
    resources:
      requests:
        memory: "256Mi"                                   
        cpu: "250m"
      limits:
        memory: "256Mi"
        cpu: "250m"
  - name: mysql-checker
    image: centos
    resources:
      requests:
        memory: "1Gi"
        cpu: "500m"
      limits:
        memory: "1Gi"
        cpu: "500m"
  containers:
  - name: app
    image: images.my-company.example/app:v4
    env:
    - name: MYSQL_ROOT_PASSWORD
      value: "password"
    resources:
      requests:
        memory: "1Gi"
        cpu: "500m"
      limits:
        memory: "1Gi"
        cpu: "500m"
  - name: log-aggregator
    image: images.my-company.example/log-aggregator:v6
    resources:
      requests:
        memory: "1Gi"
        cpu: "250m"
      limits:
        memory: "1Gi"
        cpu: "250m"
  1. Find the highest resource request or limit on init containers. In this example, 1 Gi for memory and 500m for CPU.
  2. Calculate the sum of all application container requests or limits. In this example, 2 Gi for memory and 750m for CPU.
  3. Compare the values and use the higher one as the effective request or limit: 2 Gi for memory and 750m for CPU.