How does the distribution of PHP processes across multiple cores work when handling multiple requests?
When handling multiple requests, PHP processes can be distributed across multiple cores by using a process manager like PHP-FPM (FastCGI Process Manager). PHP-FPM can manage a pool of PHP processes and distribute incoming requests to these processes, utilizing multiple CPU cores efficiently.
// Sample PHP-FPM configuration file (php-fpm.conf)
[global]
pid = /var/run/php-fpm.pid
error_log = /var/log/php-fpm.log
[www]
user = www-data
group = www-data
listen = /var/run/php-fpm.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35