PHP & Zend Engine (50 Qs)•Part 3: Production Tuning, Asynchronous Workers & High Scale (25 - 35)
PHP-FPM (FastCGI Process Manager) Architecture and Tuning.
senior LevelAsync & PromisesSystem Design
In Simple Words: PHP-FPM runs a master process that manages worker pools to execute PHP scripts:
- Share-Nothing Architecture: Each HTTP request is handled by an isolated worker process. When the request finishes, the entire request memory is wiped clean, preventing memory leaks between requests.
- Process Manager Modes:
static: Fixed number of workers running continuously. Maximum performance for dedicated web servers.dynamic: Scales workers betweenpm.min_spare_serversandpm.max_childrenbased on traffic.ondemand: Spawns workers only when requests arrive (ideal for low-traffic shared hosting).