Just out of curiosity, where can you use this json configuration? Is it Azure?
Back to the question.
I could learn more about CPU related features and schedulers, but I don’t know why you would set
CpuPeriod and not
CpuQuota. The documentation you quoted mentions that
CpuPeriod has a default value:
10000, but it does not mention that for
There is an other parameter in the docs, “
--cpus”, which is
CpuQuota / CpuPeriod
It means if you want to achieve the same as you could by using
--cpus (which is probably
Cpus in your config if it exists), you need both values. Since we know
CpuPeriod has a default value, it is not required to set, but
CpuQuota probably is.
CpuQuota also has a default value. I think the logical value would be the default
CpuPeriod multiplied by the sum of the CPUs (threads). Let’s also say you have 4 CPUs. It would mean you could use
400000 periods. Then you want to make sure a container can use CPU resources equivalent to the periods of one and a half CPU. To get 1.5, you would need to set
CpuQuota / CpuPeriod = 400000 / 266666.666667 = 1.5
Using that number is not too user friendly, so I think setting
CpuQuota and using the default value of
CpuPeriod is much easier way to limit CPU resources. Of course the easiest is just using
Cpus if that is allowed in your configuration file.
An other speculation
In this case let’s say the default value of
0. Then by dividing
25000 (or anything), you get an other
0. It either means unlimited and you did not limit CPU resources, or it means you won’t be able to use any CPU resources.
So I think if
CpuQuota has a default value, it is probably
0 and when you devide
0 means unlimited, and this is why you need to set it if you want any limit while the other value is optional.
If you play with the values in command line, you will see that you can safely set
0, but can’t set to less then
time docker run --cpu-period=25000 --cpu-quota=1 --rm ubuntu:20.04 echo hello
docker: Error response from daemon: CPU cfs quota can not be less than 1ms (i.e. 1000).
If you want to understand how things work, the best way is to try it. Except when you want to understand how your neighbour’s windows break Fortunately these cpu limit parameters will not do any harm.