in each HN i have 1 CT runing (httpd, mysql with replication)
so there is a command sequence on HN
#vzctl set 502 --cpuunits 1000 --save
Setting CPU units: 1000
Saved parameters for CT 502
#vzcpucheck
Current CPU utilization: 2000
Power of the node: 160011
ok
#vzctl set 502 --cpuunits 10000 --save
Setting CPU units: 10000
#vzcpucheck
Current CPU utilization: 11000
Power of the node: 160011
emm ok
#vzctl set 502 --cpuunits 30000 --save
Setting CPU units: 30000
#vzcpucheck
Current CPU utilization: 32250
Power of the node: 160011
emmm why 32250 not 31000??
ok, let it be...
# vzctl set 502 --cpuunits 120000 --save
..
Current CPU utilization: 126000
+6000
ok
# vzctl set 502 --cpuunits 130000 --save
Current CPU utilization: 167666
Power of the node: 160011
Warning: hardware node is overcommitted
emm, what??
# vzctl set 502 --cpuunits 124000 --save
..
Current CPU utilization: 126000
# vzctl set 502 --cpuunits 125000 --save
..
Current CPU utilization: 126000
final
# vzctl set 502 --cpuunits 126000 --save
# vzcpucheck
Current CPU utilization: 167666
Power of the node: 160011
Warning: hardware node is overcommitted
so...
why some time vzctl set and vzcpuchkeck gives different expected result.
why setting cpuunits to 126000 gives hardware overcomitted while hardware node has power of 160011
yes, I know that CT0 takes 1000
easy to check:
# vzcpucheck -v
my question is why setting cpuunits to 30000 it makes all cpu utilization not 31000 but 32250
and why while systems power is 160010, setting cpuunits to 130000 makes not 131000, but 167666 cpu utilization of the node
The answer is simple. There is some magic number 500.000 in the code which is used to round numbers. I found the origin here: wiki.openvz.org/Fairsched_API#CPU_limit
So I found my vzcpucheck value of 479343 and I want every vz container to have 1/7 of the cpu time == 68477. When I enter this with vzctl I get 71428 as the value which is set.
Here is how the 500.000 number works: 500.000/71428 is an int! The next best lower number is 62500 cpuunits. When I enter that 7 times I get underbooking (which is what I want).