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

Docker healthcheck causes higher than usual idle CPU usage #1088

Closed
tanc opened this issue Jul 9, 2018 · 39 comments
Closed

Docker healthcheck causes higher than usual idle CPU usage #1088

tanc opened this issue Jul 9, 2018 · 39 comments
Assignees
Labels
improvement Things work OK but suggestion to make them better
Milestone

Comments

@tanc
Copy link
Contributor

tanc commented Jul 9, 2018

Bug Report

Tell us about your setup

Lando: v3.0.0-beta.47
OS: MacOS 10.13.5

Tell us about your .lando.yml

recipe: drupal8
config:
  webroot: web
  via: nginx

Tell us generally about your bug

Not a bug but I noticed Lando idles at a higher CPU than the other Docker based environment I have been testing (Docker for Drupal).

When Docker for Mac is first started it's hyperkit process idles at around 2-3% CPU on my machine.

activity_hyperkit

When a Drupal 8 recipe based Lando controlled set of containers is started it idles at 15-20% CPU when using NGINX.

activity_lando_nginx

The default Drupal 8 recipe using Apache idles at around 7-8% CPU.

I've ssh'd into the app container but its not obvious which process is using CPU.

In comparison I've spun up a Drupal 8 set of containers using Docker for Drupal and this idles at basically the same amount as not having any containers spun up (around 2-3% CPU).

activity_d4d

Any idea what is causing this CPU load? It would be nice if there was no (extra) load having a Lando site up so that battery lasts longer on laptops and heat is kept to a minimum.

@tanc
Copy link
Contributor Author

tanc commented Jul 10, 2018

This gif shows the nginx and mariadb containers using CPU when idle, using docker stats:

usage nginx and mariadb

.lando.yml:

name: mytest
recipe: drupal8
config:
  webroot: gitroot/web
  database: mariadb
  xdebug: true
  via: nginx

@Etroid
Copy link
Contributor

Etroid commented Jul 24, 2018

Noticing the same issue when running a pantheon D8 recipe.

@sherakama
Copy link

sherakama commented Jul 24, 2018

I am pretty sure this is a Docker/OSX bug. See this thread: docker/for-mac#1759

I ran in to this issue as well and have updated my OS and Docker Edge to the latest. This has helped with the CPU usage during idle times significantly for me. One other factor is that often I override the database image to use a specific version of mysql. There are special flags to help with performance when doing this and you can append a :cached or :delegated flag to your image.

eg:

services:
  database:
    type: mysql:5.7:delegated

@tanc
Copy link
Contributor Author

tanc commented Aug 6, 2018

@sherakama can you point to the docs (or code) where it explains the :cached and :delegated flag in Lando? (I know about the flag generally in Docker).

I'm not sure the high idle CPU is related to that issue, although I'll keep an eye on it. With no containers running the idle CPU is very low. With Docker for Drupal or DDEV containers running idle is also very low. When running Lando containers I see idle higher. So it seems like there is some kind of polling or other regular task running that keeps CPU higher.

@justageek
Copy link

My see 250% plus cpu load for com.docker.hyperkit when starting lando, primarily with sites using the drupal8 recipe, I've been trying to troubleshoot but no luck so far, I'll be happy to contribute information and tests if anyone has any progress,

Lando - v3.0.0-beta.47

Docker
Client:
Version: 18.06.0-ce
API version: 1.38
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:05:26 2018
OS/Arch: darwin/amd64
Experimental: false

Server:
Engine:
Version: 18.06.0-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:13:46 2018
OS/Arch: linux/amd64
Experimental: true

@justageek
Copy link

This has solved my issues: https://coderwall.com/p/pl3rfg/fix-docker-for-mac-high-cpu-usage

@iBobik
Copy link

iBobik commented Jan 19, 2019

I think it is not because Docker for Mac, but because of some strange conf from Lando. I usually have stated multiple Drupal projects but only some use Lando. And only Lando's database eats ~5% of CPU while idle, other databases are on zero. Happens on both MariaDB and MySQL.

@stale
Copy link

stale bot commented Mar 18, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

@stale stale bot added the stale Issue has been auto-flagged as stale label Mar 18, 2019
@iBobik
Copy link

iBobik commented Mar 18, 2019 via email

@stale stale bot removed the stale Issue has been auto-flagged as stale label Mar 18, 2019
@dasginganinja
Copy link

I'm not noticing this issue when I use the lamp recipe. When using the drupal8 recipe I see lots of CPU comparatively.

Stats from docker stats:

lamp:
Screen Shot 2019-03-26 at 8 50 42 AM

drupal8:
Screen Shot 2019-03-26 at 8 54 36 AM

@ccharlton
Copy link
Contributor

ccharlton commented Apr 15, 2019

I've been using 'docker pause INSTANCE_1 INSTANCE_2 INSTANCE_3' for the services I'm not using at that time. It barely helps.

@stale
Copy link

stale bot commented May 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

@stale stale bot added the stale Issue has been auto-flagged as stale label May 15, 2019
@iBobik
Copy link

iBobik commented May 16, 2019 via email

@stale stale bot removed the stale Issue has been auto-flagged as stale label May 16, 2019
@stale
Copy link

stale bot commented Jun 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

@stale stale bot added the stale Issue has been auto-flagged as stale label Jun 15, 2019
@iBobik
Copy link

iBobik commented Jun 15, 2019 via email

@stale stale bot removed the stale Issue has been auto-flagged as stale label Jun 15, 2019
@stale
Copy link

stale bot commented Jul 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

@stale stale bot added the stale Issue has been auto-flagged as stale label Jul 15, 2019
@iBobik
Copy link

iBobik commented Jul 15, 2019 via email

@stale stale bot removed the stale Issue has been auto-flagged as stale label Jul 15, 2019
@MatthieuScarset
Copy link
Contributor

MatthieuScarset commented Jul 16, 2019

Indeed I confirm that using Lando drupal8 recipe use a lot of ressources compare to other Docker-based solution on Ubuntu .

Just a though here.. but is there anyway to limit memory and CPUs when running lando start ?

Something like:

lando start --memory=”1g” --memory-swap=”2g” --cpus=".5"

Example of high CPU use by two database containers of one single project (idle):
Screenshot from 2019-07-16 22-21-07

@pirog
Copy link
Sponsor Member

pirog commented Jul 16, 2019

@iBobik obviously you've never mined bitcoin before.

@MatthieuScarset
on macOS/Windows this happens automatically and is configurable generally through the Docker Destkop UI. If you are on Linux you probably need to configure your docker daemon to operate within specific resources thresholds.

you also might be able to use Lando’s service override functionality to specify resource restraints at the docker-compose level and on per service basis

@iBobik
Copy link

iBobik commented Jul 16, 2019

This issue is not complain on CPU consumption when on load, but when idle - no requests to webserver neither to database, but is still do something. This is huge energy consumption cumulatively. Only workaround is to stop Lando when not using the project.

@pirog
Copy link
Sponsor Member

pirog commented Jul 16, 2019

@iBobik yup, we can read.

@stale stale bot removed the stale Issue has been auto-flagged as stale label Oct 8, 2019
@iBobik
Copy link

iBobik commented Oct 8, 2019 via email

@ccharlton
Copy link
Contributor

@ricardoamaro got details (or a Gist) to share for us curious?

@ricardoamaro
Copy link

it's here #1088 (comment)

@stale
Copy link

stale bot commented Nov 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

@stale stale bot added the stale Issue has been auto-flagged as stale label Nov 29, 2019
@iBobik
Copy link

iBobik commented Nov 29, 2019 via email

@stale stale bot removed the stale Issue has been auto-flagged as stale label Nov 29, 2019
@RobertAKARobin
Copy link

RobertAKARobin commented Dec 2, 2019

Every time I run Lando my computer (a 3-month-old Macbook Pro) sounds like a vacuum cleaner and gets all toasty. It would be great to have a fix merged in.

Screen Shot 2019-12-02 at 9 32 23 AM

@stale
Copy link

stale bot commented Jan 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

@stale stale bot added the stale Issue has been auto-flagged as stale label Jan 1, 2020
@RobertAKARobin
Copy link

I use Lando very often and so would like to see this fixed.

@stale stale bot removed the stale Issue has been auto-flagged as stale label Jan 2, 2020
@sryanb
Copy link

sryanb commented Jan 10, 2020

I'm seeing remarkable improvements from disabling healthcheck and then running lando rebuildas described above.

Lando version: v3.0.0-rc.22
Docker Desktop: 2.1.0.5 (configured to use 1 CPU, 8GB RAM)
Macbook Pro 16" (2019) running Catalina (10.15.2)

@Dopeyr
Copy link

Dopeyr commented Jan 28, 2020

This has had a positive impact on my machine too. I was running 2 solr instances, 1 database and limiting the interval to every 60s on all services has reduced the idle load from about 60% CPU to less than 10%, typically 5%.

Does anyone know if these healthchecks are supposed to keep running? I understand they are using in the startup sequence, but are they meant to keep running post start? I don't see any messages from lando if I stop a container via docker for example.

@pirog pirog changed the title Idle CPU too high when using Lando compared to other docker containers Docker healthcheck causes higher than usual idle CPU usage Apr 1, 2020
@pirog pirog self-assigned this Apr 1, 2020
@pirog pirog added the improvement Things work OK but suggestion to make them better label Apr 1, 2020
@pirog pirog added this to the 3.0.0-rrc.3 milestone Apr 1, 2020
@pirog
Copy link
Sponsor Member

pirog commented Apr 1, 2020

So we definitely don't want to get rid of the healthcheck because we want to be able to tell the user that something is not working correctly. Also this is super helpful to the Lando team for debugging and support purposes.

That said, i don't think we need the persistent running-all-the-time healthcheck that docker provides out of the box. It also doesn't look like you can configure the docker healthcheck to do something like "run 10 times at 5 second intervals on start" which is unfortunate.

This makes me think the best-of-both-worlds resolution here would be to reimplement the healthchecks at the lando level so that we can run them post-start with some reasonable retry and backoff until they fail/succeed and then we leave the container be. Guessing that would allow the UX on the healthchecks to stay the same but would drastically cut idle CPU after an app has booted up correctly.

pirog added a commit that referenced this issue Apr 2, 2020
@pirog pirog modified the milestones: 3.0.0-rrc.3, 3.0.0-rrc.5 Apr 2, 2020
pirog added a commit that referenced this issue Apr 6, 2020
pirog added a commit that referenced this issue Apr 6, 2020
@pirog
Copy link
Sponsor Member

pirog commented Apr 6, 2020

Alright, a reimplementation of the healthcheck has been merged into master with #2136

This replace the docker healthcheck with a lando one. the relevant consequence there is the healthcheck stops after the app has started which should cut down on the idle cpu usage. guessing this will be available in the next edge release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Things work OK but suggestion to make them better
Projects
None yet
Development

No branches or pull requests