Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HyperKit high cpu consumption #2582

Closed
bypotatoes opened this issue Feb 7, 2018 · 28 comments
Closed

HyperKit high cpu consumption #2582

bypotatoes opened this issue Feb 7, 2018 · 28 comments

Comments

@bypotatoes
Copy link

Expected behavior

To have cpu level pretty same for dockerized app and not

Actual behavior

When rails app handles request level of cpu increases to 150-280% depends on how heavy page is, after few seconds it returns to normal level, instead of #2503 and similar where cpu level is permanently high

Information

macOS: version 10.13.3 (build: 17D47)
logs: /tmp/89DC5C0F-2ED3-4106-AEFB-5D79EC2AC30B/20180208-023454.tar.gz
[OK]     db.git
[OK]     vmnetd
[OK]     dns
[OK]     driver.amd64-linux
[OK]     virtualization VT-X
[OK]     app
[OK]     moby
[OK]     system
[OK]     moby-syslog
[OK]     kubernetes
[OK]     env
[OK]     virtualization kern.hv_support
[OK]     slirp
[OK]     osxfs
[OK]     moby-console
[OK]     logs
[OK]     docker-cli
[OK]     menubar
[OK]     disk

Steps to reproduce the behavior

  1. create rails application with compose, e.g follow official guide
  2. check effect for welcome page in new rails up(cpu will up to 50% what is pretty high for super simple page)
  3. to make effect more noticeable add db volume and fill db with data
  4. make request to page that request data from db
@javajosh
Copy link

I'm getting the same thing, and it looks like this has been a problem for a long time, all the way back to #82 or so. docker stats show that the containers themselves are using very little CPU, which implies that the load is in the parent hyperkit process itself. Personally, I've attempted to give more CPU cores, more RAM, and limit the potential bind mount options but it's still using a lot of CPU, and my fan is spinning.

If we can't fix this we can't have devs running docker. We will have to switch away from using docker for development and just use manually run our processes (which does not, of course, have this issue).

@gamort
Copy link

gamort commented Feb 16, 2018

I have had good luck simply brute-forcing around this issue. I installed cputhrottle http://www.willnolan.com/cputhrottle/cputhrottle.html and run a bash script whenever I restart docker to locate the hyperkit process pid and throttle it to 60%[on a 4 core system].

I have not had any issues with files being synced and performance is now decent.

I lack the time and energy to dig into yet another new framework to figure out why this is happening, cputhrottle made all our dev systems usable and I moved on.

My guess is that the stupid thing is using a huge number of file watches, by default it will scan every single hard drive and when a lot of changes happen at once, it will happily grab every single cpu just to determine that "nope, none of those files are of interest to me"

@artyfarty
Copy link

It's related to heavy I/O of rails app. If you mount the whole app directory inside a container, it will spend a considerable time on sync. I've mounted rails temp/cache directories to tmpfs in compose file and also heavily use cached or delegated mount modes to bring app speed back on earth levels.

@barat
Copy link

barat commented Mar 27, 2018

@artyfarty does even :delegated work? I think, that docker team hasn't made an implementation yet so :delegated is an alias for :cached right now ...

@artyfarty
Copy link

@barat i dunno. I believe in it :(

@javajosh
Copy link

@gamort Thanks for the suggestion; I tried that and it worked, but of course Docker was very very slow. At the end of the day, changing the mount options in docker-compose.yml to the most restrictive possible worked the best. In our case it meant mostly :ro with a few :delegated mixed in.

@alexbaumgertner
Copy link

alexbaumgertner commented Apr 26, 2018

It's related to heavy I/O

Unfortunately, in Mac OS Docker needs to operate with file system through HyperKit layer and it's make io processes slow.

I haven't tried yet but probably there is the solution: http://docker-sync.io/

Uses either native_osx, unison or rsync as possible strategies.

@artyfarty
Copy link

docker-sync has it's own reliability issues on large projects.

@axsuul
Copy link

axsuul commented Jul 13, 2018

@artyfarty Could you possibly share your docker-compose.yml for your Rails app? ❤️

@artyfarty
Copy link

artyfarty commented Jul 13, 2018

@axsuul turned out tmpfs is unreliable crap too. In the end i've gone to nfs.

here is howto that i used:
https://medium.com/@sean.handley/how-to-set-up-docker-for-mac-with-native-nfs-145151458adc

@docker-robott
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@obad2015
Copy link

/remove-lifecycle stale

@Pr0TuX
Copy link

Pr0TuX commented Dec 23, 2018

Happens here also, If any other information is needed I can provide.

Currently I'm using docker Version 2.0.0.0-mac81 (29211)
And mac os 10.14.2

Docker is currently running with kubernetes pods and system related resources and hyperkit is at about 50% CPU ussage. My mac book pro is 2.6 Ghz i7 16 GB Ram ...

Is there any workaround we can do, at least until this is fixed ?

When I'm trying to run docker-compose and start 2 containers the CPU jumps at 500% ... and my laptop can't be used anymore. Also most of docker-compose like logs or stop are responding with time out .. so I need to force quite docker to use my laptop again ..

@ruslyrossi47
Copy link

When I start my Docker Desktop community Version 2.0.0.0-mac78 (28905), I can see this process com.docker.hyperkit will consume more than 100% of CPU, so I solve this by kill all my containers and start again one by one.

@brandonbai
Copy link

brandonbai commented Jan 15, 2019

When I run jenkins with docker, the hyperkit takes up more than 300% of the cpu. But when I run other services, everything works fine.

I even heard the sound of the fan.

- version
os macOS Mojave 10.14.2
docker 18.09.0
jenkins 2.150.1

@davidkrcil
Copy link

After 5 months I have finally resolved this pain for me. I have used http://www.willnolan.com/cputhrottle/cputhrottle.html and run command: sudo ./cputhrottle 4634 50
My Mac is again my frined with no running fan.

@michaelbutler
Copy link

michaelbutler commented Feb 12, 2019

My docker for mac (version 18.09.1 Edge) takes a constant 50-80% CPU even when all containers are deleted and docker ps shows nothing running

@alexbaumgertner
Copy link

alexbaumgertner commented Feb 12, 2019

@michaelbutler try to run

docker volume ls

Maybe some volumes still exists and doing sync.
https://docs.docker.com/storage/volumes/

@Jvlythical
Copy link

Jvlythical commented Mar 29, 2019

I was able to solve it by raising the available memory for the Docker daemon from the default 2GB. You can change the available memory in Preferences > Advanced.

@axsuul
Copy link

axsuul commented Mar 29, 2019

I've had great success with delegated volumes 👍My fan still comes on but it's at least 10x better

@wuestkamp
Copy link

@michaelbutler do you have the local Kubernetes cluster enabled via Docker for Mac? Once I enable it I have constant CPU of 50%

@docker-robott
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@JamesonNetworks
Copy link

JamesonNetworks commented Jun 28, 2019

There is another issue tracking at #1759, they seem related

Web of issues:
Possibly related to:
#1759
#2582
#2926
#3499

@r9software
Copy link

I have the same issue docker takes over 140% in a laravel API with client frontend running in the same container, I read somewhere that if you increase the number of files that mac can open at the same time to millions then it should decrease the problem and it happened that way, but I can't find the command anymore, and I don't believe that is the right way to do it, does anyone has a better way of dealing with this?

@alexbaumgertner
Copy link

@r9software try this
https://blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan/

@r9software
Copy link

r9software commented Aug 9, 2019

hey @alexbaumgertner thank you that worked!

@maxfenton
Copy link

Wayback Machine link for that blog post above: https://web.archive.org/web/20161223195250/https://blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan/

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Jun 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests