2

I need to run docker container on different VMs with 80% cpu processing time limit. At the same time I don't know how many cpu/cores/threads target VM will have. Docker offers a few arguments to control cpu limits. The most suitalbe for me - cpu-quota. But looks like it's per cpu. For instance I have VM with the following configuration:

CPU(s): 2 On-line CPU(s) list: 0,1 Thread(s) per core: 1 Core(s) per socket: 2 Socket(s): 1 NUMA node(s): 1 

When I set cpu-quota to 80000 (which is 80% of 10K) then it uses just one cpu, not 2 available cpus.

Is there nay way to put 80% cpu limit in a common way to not adjust it for each VM? Literally I need to say "hey, regardless of how many cpus/cores/threads etc you have, pls let this container to use only 80%"? Is it possible? If no, what would be the way to go, put limit for each VMs individually?

1 Answer 1

3

as the website say: control cpu limits

--cpu-period means

Specify the CPU CFS scheduler period

--cpu-quota means

Impose a CPU CFS quota on the container. The number of microseconds per --cpu-period that the container is limited to before throttled

if you use --cpu-quota you must use --cpu-period first

--cpus is a more convenient alternative

--cpus 1.6

This is the equivalent of setting --cpu-period="100000" and --cpu-quota="160000"

if you want use all 2 cpus, which uses 80%:

you can use the setting: --cpu-period="80000" and --cpu-quota="200000"

if you want to run same command in every VMs:

--cpu-period="80000" --cpu-quota="$(cat /proc/cpuinfo | grep processor | wc -l)0000"

Sign up to request clarification or add additional context in comments.

4 Comments

I didn't get this one --cpu-period="80000" and --cpu-quota="200000" could pls elaborate a bit more? Why quote > period? Am I right that I have to set period & quote per each VM? There is no way to set it just once?
yes, I have to set period & quote per each VM. you can use shell to get the cpu's count aotument, which above the upated answer
Why quote > period? the document says it....
yeah did so. I use ansible so it was pretty easy

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.