mautic / docker-mautic

Docker Image for Mautic
https://www.mautic.org
374 stars 278 forks source link

High CPU usage by "[php] <defunct>" process #298

Open remcovg89 opened 2 weeks ago

remcovg89 commented 2 weeks ago

Basically we took the files from https://github.com/mautic/docker-mautic/tree/mautic5/examples/fpm-nginx and changed the docker-compose file to have a restart policy on each of the nodes "restart: always", and added the one publicly accessable container to the reverse proxy network of the nginx container.

During setup we chose to not prefix the database because that was causing issues after a restart, beyond that it's a basic setup.

We're running docker on a vps dedicated for this project. 2 CPU's 4GB ram. CPU load is constantly at their max.

Besides mautic the only containers also running on this server are nginxproxy manager to manage domain forwarding to the mautic containers

The server load over a longer period of time: Afbeelding van WhatsApp op 2024-09-30 om 11 43 12_20198335

The processes with high cpu load (cpu sorted 'ps aux') Afbeelding van WhatsApp op 2024-09-30 om 13 17 58_36c0c774

'Docker stats' identifying the worker container Afbeelding van WhatsApp op 2024-09-30 om 13 17 59_4efd1386

'top' command image

Commands "[php] ", "php /var/www/html/bin/console messenger:consume hit", "php /var/www/html/bin/console messenger:consume email" all seem to have an high CPU load, but I assume it's just an issue with that individual container.

The docker compose file:

version: '3'

x-mautic-volumes:
  &mautic-volumes
  - ./mautic/config:/var/www/html/config:z
  - ./mautic/logs:/var/www/html/var/logs:z
  - ./mautic/media/files:/var/www/html/docroot/media/files:z
  - ./mautic/media/images:/var/www/html/docroot/media/images:z
  - ./cron:/opt/mautic/cron:z
  - mautic-docroot:/var/www/html/docroot:z

services:
  db:
    image: mysql:8.0
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    volumes:
      - mysql-data:/var/lib/mysql:z
    healthcheck:
      test: mysqladmin --user=$$MYSQL_USER --password=$$MYSQL_PASSWORD ping
      start_period: 5s
      interval: 5s
      timeout: 5s
      retries: 10
    networks:
      - default

  nginx:
    image: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
      - mautic-docroot:/var/www/html/docroot:z
    depends_on:
      - mautic_web
    ports:
      - 8002:80
    networks:
      - default
      - proxy-network
    restart: always

  mautic_web:
    image: mautic/mautic:5-fpm
    links:
      - db:mysql
    volumes: *mautic-volumes

    environment:
      - DOCKER_MAUTIC_LOAD_TEST_DATA=${DOCKER_MAUTIC_LOAD_TEST_DATA}
      - DOCKER_MAUTIC_RUN_MIGRATIONS=${DOCKER_MAUTIC_RUN_MIGRATIONS}
    env_file:
      - .mautic_env
    healthcheck:
      test: cgi-fcgi -bind -connect 127.0.0.1:9000
      start_period: 5s
      interval: 5s
      timeout: 5s
      retries: 100
    depends_on:
      db:
        condition: service_healthy
    networks:
      - default
    restart: always

  mautic_cron:
    image: mautic/mautic:5-fpm
    links:
      - db:mysql
    volumes: *mautic-volumes
    environment:
      - DOCKER_MAUTIC_ROLE=mautic_cron
    env_file:
      - .mautic_env
    depends_on:
      mautic_web:
        condition: service_healthy
    networks:
      - default
    restart: always

  mautic_worker:
    image: mautic/mautic:5-fpm
    links:
      - db:mysql
    volumes: *mautic-volumes
    environment:
      - DOCKER_MAUTIC_ROLE=mautic_worker
    env_file:
      - .mautic_env
    depends_on:
      mautic_web:
        condition: service_healthy
    networks:
      - default
    restart: always

volumes:
  mysql-data:
  mautic-docroot:

networks:
  default:
    name: ${COMPOSE_PROJECT_NAME}-docker
  proxy-network:
    external: true

At this point we don't even have any mailcampaigns setup in mautic, we did setup visitor tracking for one of our websites, but there aren't a lot of visitors or anything that would explain this load.

Any suggestions what we could check/optimize to lower this CPU load, or figure out what exactly is causing the load?