Performance Tuning
Toutes les configurations PHP, MySQL, PostgreSQL et Apache sont pilotables depuis le fichier .env.
Modifier les variables + docker compose up -d suffit pour appliquer les changements.
Architecture
CSWeb utilise un mecanisme de templates envsubst :
- Les fichiers
docker/php/php.inietdocker/apache/*.confcontiennent des variables${VAR} - Au demarrage du container,
docker-entrypoint.shexecuteenvsubstpour generer les fichiers finaux - MySQL et PostgreSQL recoivent leurs parametres via
command:dansdocker-compose.yml
Variables par composant
PHP
| Variable | Default | Description |
|---|---|---|
PHP_MEMORY_LIMIT | 512M | Memoire max par processus PHP |
PHP_MAX_EXECUTION_TIME | 300 | Temps max d'execution (secondes) |
PHP_MAX_INPUT_TIME | 300 | Temps max de parsing input |
PHP_UPLOAD_MAX_FILESIZE | 100M | Taille max d'un fichier uploade |
PHP_POST_MAX_SIZE | 100M | Taille max d'une requete POST |
PHP_SESSION_GC_MAXLIFETIME | 7200 | Duree de session (secondes) |
PHP_OPCACHE_MEMORY | 128 | Memoire OPcache (MB) |
PHP_OPCACHE_MAX_FILES | 10000 | Nombre max de fichiers en cache |
Exemple .env :
PHP_MEMORY_LIMIT=1G
PHP_MAX_EXECUTION_TIME=600
PHP_OPCACHE_MEMORY=256Verifier apres deploiement :
docker exec csweb-app php -i | grep memory_limit
docker exec csweb-app php -i | grep max_execution_timeProfils de dimensionnement
Profil Dev — 1 a 5 utilisateurs, laptop
# PHP
PHP_MEMORY_LIMIT=256M
PHP_MAX_EXECUTION_TIME=120
PHP_OPCACHE_MEMORY=64
PHP_OPCACHE_MAX_FILES=4000
# MySQL
MYSQL_MAX_CONNECTIONS=50
MYSQL_INNODB_BUFFER_POOL_SIZE=128M
# PostgreSQL
PG_MAX_CONNECTIONS=50
PG_SHARED_BUFFERS=128MB
PG_EFFECTIVE_CACHE_SIZE=512MB
# Apache
APACHE_MAX_REQUEST_WORKERS=25
APACHE_SERVER_LIMIT=25RAM recommandee : 4 GB
Formules de dimensionnement
Memoire totale requise
RAM_TOTALE >= (APACHE_MAX_REQUEST_WORKERS x PHP_MEMORY_LIMIT moyen)
+ MYSQL_INNODB_BUFFER_POOL_SIZE
+ PG_SHARED_BUFFERS
+ 1 GB (OS + overhead)En pratique, les processus PHP utilisent ~50-100 MB en moyenne (rarement le max).
Exemple pour 150 workers :
150 x 100MB + 512MB + 512MB + 1GB = ~17 GB (estimation realiste)Connexions base de donnees
MYSQL_MAX_CONNECTIONS >= APACHE_MAX_REQUEST_WORKERS + 20 (marge admin/cron)
PG_MAX_CONNECTIONS >= APACHE_MAX_REQUEST_WORKERS + 20Apache ServerLimit
APACHE_SERVER_LIMIT >= APACHE_MAX_REQUEST_WORKERS (obligatoire)Commande de verification
La commande csweb:check-config affiche toute la configuration et detecte les incoherences :
# Afficher la configuration complete
docker exec csweb-app php bin/console csweb:check-config
# Avec test des connexions MySQL et PostgreSQL
docker exec csweb-app php bin/console csweb:check-config --test-connections
# Sortie JSON (pour monitoring automatise)
docker exec csweb-app php bin/console csweb:check-config --jsonRecommandations automatiques :
- Apache MaxRequestWorkers > MySQL max_connections
- ServerLimit < MaxRequestWorkers
- post_max_size < upload_max_filesize
- memory_limit trop bas
Workflow de modification
# 1. Modifier les variables dans .env
nano .env
# 2. Recreer les containers
docker compose up -d
# 3. Verifier la configuration
docker exec csweb-app php bin/console csweb:check-config
# 4. Verifier PHP specifiquement
docker exec csweb-app php -i | grep memory_limitLes changements sont appliques au redemarrage des containers (docker compose up -d). Pas besoin de rebuild (--build).
Voir aussi
- Modes de Deploiement - Local et Remote pour chaque base
- Docker Production - Deploiement production securise
- Variables d'Environnement - Reference complete
.env - check-config - Reference de la commande CLI