V
V
Valioozz2020-01-23 14:28:10
linux
Valioozz, 2020-01-23 14:28:10

Are requests for Cgroups CPU shares equal when running Kubernetes on nodes with different number of cores (using Docker)?

I conducted a couple of experiments
On an 8 -core system and on a 4 - core system, I set 100mup a CPU request for a container in Kubernetes
in both cases, it eventually ended up at the cgroups level in the same way (as I actually expected)
cpu.shares=102
The Kubernetes documentation in the “ Meaning of CPU ” section says

CPU is always requested as an absolute quantity, never as a relative quantity; 0.1 is the same amount of CPU on a single-core, dual-core, or 48-core machine.

Which confused me a little, but a little lower there is also a section
How Pods with resource limits are run
And they write about the transformation
When using Docker:
- The spec.containers[].resources.requests.cpu is converted to its core value, which is potentially fractional, and multiplied by 1024. The greater of this number or 2 is used as the value of the -- cpu-shares flag in the docker run command.

From which I concluded that
0.1 is the same amount of CPU on a single-core, dual-core, or 48-core machine

0.1 in any situation is converted to 100m (I checked this too) and the value 102 will leak into the balls everywhere. It turns out that when you set requests, you don’t need to count something, but because shares are used in the calculation as coefficients
A ball is a relative numerical parameter; its value only makes sense in comparison with the values ​​of other shares in the same cgroup

then in the end, anyway, on different systems we will receive different power with the same requests.
If someone has studied the issue in detail, please help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valioozz, 2020-02-07
@Valioozz

Not equal, the value of shares will always be relative, from which I concluded that this sentence refers to limits that will be absolute on any system.

0.1 is the same amount of CPU on a single-core, dual-core, or 48-core machine

I analyzed the topic in more detail in the post - https://medium.com/targetprocess/setting-consuming...

V
Vitaly Karasik, 2020-01-24
@vitaly_il1

0.1 is the same amount of CPU on a single-core, dual-core, or 48-core machine

I have not studied deeply and have not tested, but IMHO this statement is correct.
In general, the K8S system is complex and there may be nuances in implementation. For all practical decisions, I advise you to base it on testing your system (code) with a load close to the real one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question