Automattic / vip-cli

The VIP-CLI
https://docs.wpvip.com/vip-cli/
MIT License
58 stars 16 forks source link

Elasticsearch service taking too much memory [Maybe only Question] #1787

Closed luislard closed 4 months ago

luislard commented 6 months ago

Expected/Desired Behavior

Currently when starting an environment with elasticsearch the ES container takes too much memory.

Dont know if it is a known issue or if there should be documentation on how to change the config for this.

Actual Behavior

See docker stats output: image

Steps to Reproduce the Problem

OS: Linux Ubuntu 22.04 VIP CLI: 2.39.0

➜  ~ docker -v
Docker version 26.0.0, build 2ae903e
➜  ~ docker-compose -v
Docker Compose version v2.26.1-desktop.1
➜  ~ docker context ls
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                     KUBERNETES ENDPOINT   ORCHESTRATOR
default *           moby                Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                                               
desktop-linux       moby                Docker Desktop                            unix:///home/johndoe/.docker/desktop/docker.sock                         

With docker using default context (not docker desktop) and the following parameters

vip dev-env create --app-code="./vip" --slug="acme-website" \
  --title="Acme Website" --php="8.2" \
  --wordpress="6.5" \
  --mu-plugins="demo" \
  --multisite=subdirectory \
  --xdebug \
  --mailpit \
  --phpmyadmin \
  --elasticsearch \
  --photon

And then running

vip dev-env start --slug=acme-website

The container is getting too much memory.

(Optional) Additional notes

Tried this:

docker update --memory "6g" --memory-swap "6g" <container_id>

But kills the ES container.

sjinks commented 6 months ago

Out of the box, Elasticsearch's default settings automatically size your JVM heap based on node role and total memory; by default, it is up to half of the physical RAM, capping at 32GB.

However, it is possible to limit ES's appetites by setting the ES_JAVA_OPTS environment variable.

What you need to do:

  1. Locate the directory where the dev env configuration is located (LOCATION in the output of vip dev-env start)
  2. In that directory, create a .lando.local.yml file with the following content:
    services:
    elasticsearch:
    type: compose
    services:
      environment:
        ES_JAVA_OPTS: "-Xms512m -Xmx512m"

    You must set the appropriate values for -Xms (the initial size of total heap space) and -Xmx (the maximum size of total heap space).

  3. Restart your dev environment; ES should consume less memory now.

Please let me know if that helps.