Resources

Pod CPU resources

Great article based on which below info is created. Find inside:

  • explanation of CPU resource and limits for k8s Pod

  • Prometheus queries to monitor Pod metrics

apiVersion: v1
kind: Pod
metadata:
  name: my-app
spec:
  containers:
  - name: app
    image: my.private.registry/my-app
    resources:
      requests:              // we are talking about it
        memory: "64M"
        cpu: "250m"
      limits:
        memory: "128M"
        cpu: "500m"

1 CPU Unit = 1024 CPU Shares

Below is how CFS will balance PODs with different CPU Unit resource configuration among cores

A CPU requests unit can be understood as the percentage of a given CPU period that is guaranteed to Pod.

a 750m CPU for a period of 100 ms means that a POD is guaranteed to have 75 ms of CPU time each 100 ms (on one or multiple cores). A 5000m CPU for a period of 1s means that a Pod is guaranteed to have 5s of CPU each 1s (1s on each of 5 cores).

It does not mean that if POD uses less resources than it requested, the CPU will remain idle. If another Pod is runnable at that time, CFS will schedule that Pod.

CPU limit unit can be understood as the percentage of each scheduler CPU period (100 ms) that a Pod cannot exceed. E.g.: limit of 750 m CPU means that each 100 ms period POD cannot use more than 75 ms of CPU time.

When an application attempts to use more CPU than it is limited to — CFS will throttle it.

Last updated