Minikube: CPU on MacOS but the sum of CPU usage inside minikube is not equal to that on the host

Created on 8 Aug 2020  路  10Comments  路  Source: kubernetes/minikube


Steps to reproduce the issue:

  1. minikube start --cpus=6 --memory=14000MB --driver=docker --disk-size='200g'
  2. do minikube ssh and execute top inside the virtual machine. The total cpu is about <30%. (see below)
  3. execute top in the host Mac machine (not in virtual machine). The cpu is much higher. often 80%~120%.
  4. execute docker stats and see minikube only takes <30% cpu.
  5. Problem: Minikube by itself seems to occupy little resource (30% cpu on idle), but the resources in my host machine is eaten a lot (120% cpu)! This is even worse when having some workload - minikube reports 100% cpu, while on host it is 600% cpu!!!

The output of "2.":

top - 00:12:01 up 3 days,  1:56,  0 users,  load average: 0.15, 3.28, 2.66
Tasks:  50 total,   1 running,  49 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.5 us,  1.0 sy,  0.0 ni, 98.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  16014.9 total,   7763.4 free,   2283.4 used,   5968.2 buff/cache
MiB Swap:   1024.0 total,   1017.0 free,      7.0 used.  13839.4 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                      
   2025 root      20   0  980052 791996  72964 S   8.7   4.8   1:59.87 kube-apiserver                                               
   1153 root      20   0 3463388 122656  66228 S   5.0   0.7   0:51.14 kubelet                                                      
   2015 root      20   0  213464 118052  58988 S   4.0   0.7   0:28.32 kube-controller                                              
   2013 root      20   0   10.3g 178020  34840 S   3.3   1.1   0:33.68 etcd                                                         
    484 root      20   0 5650336 136876  47196 S   1.7   0.8   0:41.73 dockerd                                                      
   3315 root      20   0  147612  35084  28552 S   1.0   0.2   0:03.58 coredns                                                      
   2035 root      20   0  146420  42384  30436 S   0.7   0.3   0:04.07 kube-scheduler                                               
  17779 docker    20   0    6108   3268   2736 R   0.3   0.0   0:00.26 top                                                          
      1 root      20   0   22448  14292   8572 S   0.0   0.1   0:06.76 systemd       

The output of "3."

PID    COMMAND      %CPU  TIME     #TH    #WQ  #PORTS MEM    PURG   CMPRS  PGRP  PPID  STATE    BOOSTS           %CPU_ME %CPU_OTHRS
52495  com.docker.h 122.7 27:01:12 26     1    50     28G    0B     8250M- 52481 52492 sleeping *0[1]            0.00000 0.000

The output of "4":

CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
62207ba7bac7        minikube            22.72%              1.364GiB / 13.67GiB   9.98%               2.14MB / 26.3MB     0B / 0B             618
184f6e834ebc        mysql               1.62%               393.7MiB / 15.64GiB   2.46%               5.06MB / 1.2MB      0B / 0B             41


Full output of failed command:

N/A

Full output of minikube start command used, if not already included:

N/A

Optional: Full output of minikube logs command:

areperformance cdocker-driver kinsupport omacos prioritimportant-longterm triagneeds-information

All 10 comments

Hey @fzyzcjy thanks for opening this issue, and sorry for the delayed response. My guess is that the overhead of running docker is being included in the CPU of the host.

I'm not sure if there's much we can do about this right now, although I'm following related issues -- https://github.com/docker/roadmap/issues/12

@priyawadhwa So why does docker cause sooooo much CPU? IMHO docker is known as very lightweight. Thanks very much!

Hey @fzyzcjy it could be related to this comment -- https://github.com/docker/roadmap/issues/12#issuecomment-666279931 -- you could try their edge build to see if that improves the CPU usage on your machine?

@priyawadhwa Thanks!

Hey @fzyzcjy did that fix things for you?

@priyawadhwa Sorry my environment cannot be easily updated to the edge build. So I have not tried it yet :/ But if it is stable release I may be able to do so. Thanks for your reply!

@fzyzcjy no worries :)

@fzyzcjy do you mind sharing how may CPUs your docker desktop been allocated ?

@medyagh allocate 12 core on my mac mini with 6 core 12 thread. And when starting minikube I use "6 core" as a starting parameter

docker:

image

start command

minikube start --cpus=6 --memory=16000MB --driver=docker --disk-size='100g' --registry-mirror="http://host.docker.internal:5000" --insecure-registry="host.docker.internal:5000" --v=5

@fzyzcjy that is interesting I wonder if this is true for any other Docker container.

it might be a docker limitation in advertisting the CPUs

@fzyzcjy u could try to run a docker with high CPU and then check if docker respect that

docker run -d -t --privileged --cpus=12 --memory=13900mb ubuntu

and then exec into the container

docker exec -it

Was this page helpful?
0 / 5 - 0 ratings