mgattolla
(Mario Gattolla)
August 29, 2024, 9:42am
1
Hi , i hope someone can help me solve this problem.
I’m a web developer and when i try to reload local pages it takes a long time. When page contains a lot of code it can take up to 5/10 minutes.
Checking docker containers results that the PHP container take 95%+ of the CPU usage on pages reloads
I tried searching corrupted files without results with this:
find /var/lib/docker/containers/ -name *-json.log -exec bash -c ‘jq ‘.’ {} > /dev/null 2>&1 || echo “file corrupt: {}”’
Here my CPU usage during page reload , it looks like he’s using only 1 CPU
Thanks You for the help
So you run php in Docker and it takes a long time. How should we help?
We don’t know your code, we don’t know if it is faster without Docker on your local machine.
You didn’t share your Dockerfile and you didn’t share your command/compose.
You need to provide more context and details.
mgattolla
(Mario Gattolla)
August 29, 2024, 2:51pm
3
I’m sorry you right , here my docker-compose
version: '3.5'
services:
php:
restart: unless-stopped
working_dir: /var/www
build:
context: 'https://github.com/organization/docker-php.git'
target: fpm
args:
PRODUCTION: 0
ENABLE_XDEBUG: 1
ENABLE_LIBREOFFICE_WRITER: 1
ENABLE_BACKUP_TOOLS: 1
ENABLE_OPCACHE: 0
PHP_VERSION: '8.2'
expose:
- 9000
user: '1000:1000'
environment:
DOCK: 1
depends_on:
- redis
networks:
- project.ktm_internal_network
- shared_db_network
volumes:
- './src/:/var/www'
nginx:
restart: unless-stopped
working_dir: /var/www
build:
context: 'https://github.com/organization/docker-nginx.git#main'
depends_on:
- php
ports:
- '80:80'
expose:
- '80'
networks:
- project.ktm_internal_network
- reverse_proxy_network
volumes:
- './src/:/var/www'
- './configs/nginx/nginx.conf:/etc/nginx/nginx.conf'
- './configs/nginx/sites-available:/etc/nginx/sites-available'
- './configs/nginx/conf.d/upstream.conf:/etc/nginx/conf.d/upstream.conf'
mailhog:
restart: unless-stopped
expose:
- 1025
- '8025'
image: 'mailhog/mailhog:latest'
ports:
- '8025:8025'
networks:
- project.ktm_internal_network
scheduler:
restart: unless-stopped
working_dir: /var/www
build:
context: 'https://github.com/organization/docker-php.git'
target: scheduler
args:
PRODUCTION: 0
ENABLE_XDEBUG: 1
ENABLE_LIBREOFFICE_WRITER: 1
ENABLE_BACKUP_TOOLS: 1
ENABLE_OPCACHE: 0
PHP_VERSION: '8.2'
expose:
- 9000
user: '1000:1000'
depends_on:
- redis
networks:
- project.ktm_internal_network
- shared_db_network
volumes:
- './src/:/var/www'
worker:
restart: unless-stopped
working_dir: /var/www
build:
context: 'https://github.com/organization/docker-php.git'
target: worker
args:
PRODUCTION: 0
ENABLE_XDEBUG: 1
ENABLE_LIBREOFFICE_WRITER: 1
ENABLE_BACKUP_TOOLS: 1
ENABLE_OPCACHE: 0
PHP_VERSION: '8.2'
expose:
- 9000
user: '1000:1000'
depends_on:
- redis
networks:
- project.ktm_internal_network
- shared_db_network
volumes:
- './src/:/var/www'
composer:
restart: unless-stopped
working_dir: /var/www
build:
context: 'https://github.com/organization/docker-php.git'
target: composer
args:
PRODUCTION: 0
ENABLE_XDEBUG: 1
ENABLE_LIBREOFFICE_WRITER: 1
ENABLE_BACKUP_TOOLS: 1
ENABLE_OPCACHE: 0
PHP_VERSION: '8.2'
expose:
- 9000
user: '1000:1000'
networks:
- project.ktm_internal_network
volumes:
- './src/:/var/www'
- './configs/composer/auth.json:/.composer/auth.json'
node:
working_dir: /var/www
image: 'organization/node:alpine-lts'
ports:
- '3000:3000'
expose:
- '3000'
networks:
- project.ktm_internal_network
volumes:
- './src/:/var/www'
redis:
restart: unless-stopped
image: 'redis:5'
expose:
- 6379
networks:
- project.ktm_internal_network
websocket:
restart: unless-stopped
working_dir: /var/www
build:
context: 'https://github.com/organization/docker-php.git'
target: websocket
args:
PRODUCTION: 0
ENABLE_XDEBUG: 1
ENABLE_LIBREOFFICE_WRITER: 1
ENABLE_BACKUP_TOOLS: 1
ENABLE_OPCACHE: 0
PHP_VERSION: '8.2'
expose:
- 9000
user: '1000:1000'
depends_on:
- php
networks:
- project.ktm_internal_network
- reverse_proxy_network
- shared_db_network
volumes:
- './src/:/var/www'
networks:
project.ktm_internal_network:
name: project.ktm_internal_network
driver: bridge
reverse_proxy_network:
external: true
shared_db_network:
external: true
I can’t share project for privacy but the same project on other 4 different machine runs without problems, it loads the same page in 2/3 seconds , my PC requires 2/3 min.
The problems occurs on every project.
Projects are written with PHP, HTML, CSS , JS using a framework called Laravel (PHP and Laravel are updated to the latest version) .
IDE : PhpStorm (latest version)
Here some info about my Laptop :
CPU :
RAM: 16GB
GPU: GTX 3060 8gb
Tell me if You need more info