I have a server with a 2.4GHz processor. And there are several cgroups, each one allowed to use 25% of CPU. That's equal to 600MHz.
Then I replace the CPU with a faster one, let's say 3.0GHz. If I use cpu.shares
, my containers will continue to get 25% of 3.0GHz which is now equal to 750MHz.
That means that after CPU replacement I have to reconfigure my cgroups to make them consume not more than 20% of CPU.
Is there a way to avoid this trouble during a CPU upgrade?
Best Answer
Shares are relative among groups. For example, assigning 25% of CPU means that a cgroup will observe "at least" that much of CPU, but it can use more. From the red hat docs on cgroups:
If you want a hard limit on CPU bandwidth, you can use
cpu.cfs_quota_us
andcpu.cfs_period_us
. From the Kernel's CFS docs:However, neither of these two options will allow you to port a group between distinct CPUs without having to change the cgroups configuration.