Configuration PHP-FPM (FastCGI Process Manager) pour performance et stabilité.
PHP-FPM (FastCGI Process Manager) est le mode d'exécution PHP recommandé pour production — daemon gérant pool de processes PHP workers. Tuning critique pour performance et stabilité d'applications PHP (WordPress, Magento, Symfony, Laravel).
Fichier config : `/etc/php/8.x/fpm/pool.d/www.conf` (par défaut).
Process Manager modes :
(1) **static** — fixed number of children, predictable memory usage, idéal high-traffic constant.
(2) **dynamic** (default) — `pm.max_children`, `pm.start_servers`, `pm.min_spare_servers`, `pm.max_spare_servers` — adapte selon load.
(3) **ondemand** — workers créés on-demand, idéal low-traffic ou multi-pool conservation memory.
Paramètres critiques :
(1) **pm.max_children** — max workers concurrent. Formule : (Total RAM - other services) / average PHP memory per request. Exemple : 8 GB serveur, 1.5 GB autres services, 100 MB par worker → max_children = (8000-1500)/100 = 65.
(2) **pm.max_requests = 500** — restart worker après N requests (prevent memory leaks dans extensions).
(3) **request_terminate_timeout = 60s** — kill workers stuck > 60s (protect against runaway).
(4) **listen.backlog = 511** — socket backlog (match somaxconn).
(5) **catch_workers_output = yes** — capture worker stderr (debugging).
(6) **php_admin_value[memory_limit] = 256M** — per-request memory limit.
Monitoring : (1) **pm.status_path = /status** — expose stats endpoint (process count, idle, active, requests/sec) ; (2) **slowlog = /var/log/php-fpm-slow.log** + **request_slowlog_timeout = 5s** — log slow requests ; (3) Prometheus php-fpm exporter ; (4) Datadog PHP-FPM integration.
OPcache : critique — `opcache.enable=1`, `opcache.memory_consumption=256` (or more), `opcache.max_accelerated_files=10000`, `opcache.validate_timestamps=0` (production, restart fpm after deploy), `opcache.preload` (PHP 7.4+ massive perf boost). Compétences LFCE.
200+ certifications, 400 000+ questions, examens blancs chronométrés.
Voir le catalogue →