Docker Community Forums

Share and learn in the Docker community.

Mixing reserved and dynamic core allocation


(GIovanni Quattrocchi) #1

Hello,
I would like to be able to allocate cores and portions of cores to containers.
For example let’s say I have 3 cpus and 2 container instances C1 and C2 and I want to reserve one complete core to both containers and split the remaining core with a particular rate, let’s say 80/20.
So the idea is to have:

  • C1 with core0 reserved (100%) and 80% of core1
  • C2 with core2 reserved (100%) and 20% core1.

I tried with cpu-period and cpu-quota using stress to run the containers at full speed:

docker run -d --name=C1 --cpu-period=100000 --cpu-quota=180000 --cpuset-cpus="0,1" progrium/stress --cpu 2
docker run -d --name=C2 --cpu-period=100000 --cpu-quota=120000 --cpuset-cpus="1,2" progrium/stress --cpu 2

I got:

  • C1 = 160% (80% cpu0, 80% cpu1) instead of 180% (100% of cpu0, 80% cpu1)
  • C2 = 120% (60% cpu1, 60% cpu2) instead of 120% (20% of cpu1, 100% cpu 2)

I tried also with cpu-shares:

docker run -d --name='C1' --cpu-shares=80 --cpuset-cpus="0,1" progrium/stress --cpu 2
docker run -d --name='C2' --cpu-shares=20 --cpuset-cpus="1,2" progrium/stress --cpu 2

I got:

  • C1 = 200% (100% cpu0, 100% cpu1) instead of 180% (100% of cpu0, 80% cpu1)
  • C2 = 100% (0% cpu1, 100% cpu2) instead of 120% (20% of cpu1, 100% cpu2)

Is there a way to achieve the behavior I’m looking for?