google / cadvisor

Analyzes resource usage and performance characteristics of running containers.
Other
17.25k stars 2.33k forks source link

container_spec_cpu_shares error margin #3599

Open Homulvas opened 2 months ago

Homulvas commented 2 months ago

While investigating some CPU pressure issues I looked into how container_spec_cpu_shares metric is calculated. The formula is 2 + ((weight-1)*262142)/9999 from https://github.com/google/cadvisor/blob/master/container/common/helpers.go#L263. With a CPU weight of 1 this translates to 2. The next jump would be 2 to 28.

My question is this really an accurate representation of weights (or k8s requests) at the lower range of the spectrum? If a machine has many cores wouldn't the weight of 1 translate into a much higher value than 2 (assuming that we are splitting all of the cores 10000 ways)?