0

I have a contanerized microservice (i.e. running docker container) for which i have assigned 8 cpu cores as resources on docker desktop ( please see attached image). But i suspect that all the cpus (0,1,2...7) do not share load evenly and hence the response time of my tested microservice doesn't get reduced as expected. I have also tried to allocate the cpu's via command docker run --cpuset-cpus="0-7" -p 8081:8080 myimage-docker . For each cpu in the cpuset, i want to see it's utilization stats in terms of % cpu usage. Is there a docker command that let me see all the 8 cpu's utilization at once during the docker container run. Something like ..

cpu0 - 12.5%
cpu1 - 12.5%
cpu2 - 12.5%
cpu3 - 12.5%
cpu4 - 12.5%
cpu5 - 12.5%
cpu6 - 12.5%
cpu7 - 12.5%

docker Desktop Image

jks
  • 129
  • 1
  • 4
  • 11

1 Answers1

0

Here's how you can measure how evenly load is spread among CPUs.

Use this command to get a shell inside the Moby VM:

docker run -it --rm --privileged --pid=host justincormack/nsenter1

Then run this command:

mpstat -P ALL 1 100

That will measure per-cpu usage every second for 100 seconds. Afterwards, it will display averages for each core.

Nick ODell
  • 15,465
  • 3
  • 32
  • 66
  • i used command like docker run --rm --privileged --pid=host -p 8081:8080 myimage-docker . How to find the value of host in "--pid=host" .Could you please elaborate. Moreover, the mpstat -P ALL 1 100 seems a linux command , but i need its windows equivalent command. – jks Oct 01 '20 at 21:55
  • No, I mean type the command as it literally appears above. `--pid=host` turns off pid namespaces. `Moreover, the mpstat -P ALL 1 100 seems a linux command` Docker for Windows uses a Linux VM to run containers inside of. In fact, you do want a Linux command here. – Nick ODell Oct 01 '20 at 22:12
  • so you mean i should go inside docker container via ssh . The command like docker exec -it /bin/bash to get a bash shell in the container and then run mpstat -P ALL 1 100 command. Right ? – jks Oct 02 '20 at 01:43
  • No, I mean you need to get inside the Moby VM, not a container within that VM. See e.g. [here](https://www.bretfisher.com/getting-a-shell-in-the-docker-for-windows-vm/). – Nick ODell Oct 02 '20 at 02:41