0
  • Throttling stats are available in /sys/fs/cgroup/cpu/cpu.stat

  • As per documentation of k8s CPU requests, the number is translated
    into a value that goes into /sys/fs/cgroup/cpu/cpu.shares

  • If container A on a node has cpu.shares value twice that of container B, then it will get twice amount of time if both are trying to run simultaneously.

  • Is this considered as throttling for container B based on cpu.shares value?

  • If so, how can we measure this kind of throttling?

Sameer Naik
  • 1,326
  • 1
  • 13
  • 28

1 Answers1

2

First of all CPU shares don't make sense until after CPU pressure occurs. As long as there is enough CPU all tasks may run for as much time as they want.

Second, CPU requests do not cause throttling, only limits do. For more details please read more about Quality of Service for Pods.

You can measure CPU throttling due to CPU limits using Metrics-server or Prometheus like that: https://github.com/kubernetes-monitoring/kubernetes-mixin/blob/master/alerts/resource_alerts.libsonnet#L143

Vasili Angapov
  • 8,061
  • 15
  • 31
  • One followup question, If multiple cgroups are ready to run at a time, how CFS picks up the one to run and how does it ensure that they get CPU time based on their relative `cpu.share` value? I found some articles mentioning red-black tree data structure but that seems to refer to least-recently-ran kind of algorithm – Sameer Naik Jan 17 '22 at 20:20