Increase PHP Processes

If you need to increate the PHP processes such as maximum number of children, servers, spare servers or requests you can do this from the command line Based on blog post by Servers for Hackers I made this setup for servers running current PHP 8.1:

sudo sed -i "s/pm.start_servers = .*/pm.start_servers = 4/" /etc/php/8.1/fpm/pool.d/www.conf
sudo sed -i "s/pm.min_spare_servers = .*/pm.min_spare_servers = 2/" /etc/php/8.1/fpm/pool.d/www.conf
sudo sed -i "s/pm.max_spare_servers = .*/pm.max_spare_servers = 4/" /etc/php/8.1/fpm/pool.d/www.conf
sudo sed -i "s/;pm.max_requests = .*/pm.max_requests = 1000/" /etc/php/8.1/fpm/pool.d/www.conf

This to deal with this error we had recently

[07-Oct-2022 03:59:00] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 6 total children

When I check current max children and servers I found

forge@server-name:~/site.com/current$ cat /etc/php/8.1/fpm/pool.d/www.conf |grep max_children
;   static  - a fixed number (pm.max_children) of child processes;
;  pm.max_children  - the maximum number of children that can
;  pm.max_children  - the maximum number of children that
pm.max_children = 20
forge@server-name:~/site.com/current$ cat /etc/php/8.1/fpm/pool.d/www.conf |grep start_servers
;  pm.start_servers  - the number of children created on startup.
pm.start_servers = 2
forge@server:~/site.com/current$ cat /etc/php/8.1/fpm/pool.d/www.conf |grep pm.min_spare_servers
; pm.min_spare_servers - the minimum number of children in 'idle'
pm.min_spare_servers = 1
forge@server:~/site.com.com/current$ cat /etc/php/8.1/fpm/pool.d/www.conf |grep pm.max_spare_servers
; pm.max_spare_servers - the maximum number of children in 'idle'
pm.max_spare_servers = 3
forge@server:~/site.com/current$ cat /etc/php/8.1/fpm/pool.d/www.conf |grep pm.max_requests
;pm.max_requests = 500

so I realized it already had quite a number of concurrent child processes allowed but only two servers at the start.

Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.