This blog post will show you how to setup PHP FPM on-demand child workers in PHP 7.x to increase website traffic.
My blog was experiencing a number of slow page loads and often running “sudo service php7.0-fpm restart” would resolve the problem. I have blogged before about setting up Ubuntu Servers on AWS, Digital Ocean and Vultr but this post is about debugging and speeding up PHP on Ubuntu self-managed servers.
I tried the normal tweaks in “/etc/php/7.0/fpm/php.ini” like
memory_limit = 512M
I setup servers like this.
I had even set up a temporary NGINX and php7.0-fpm restart ever 5 and 1-minute respectively until I had time to look into this.
I checked out the PHP7.0-fpm.log and I found the following
Setting up a PHP-FPM pool
Read the official guide here on configuring PHP FPM pools etc.
I edited “/etc/php/7.0/fpm/pool.d/www.conf” and added the following to set up a pool of PHP-FPM servers.
You may need more or fewer child processes depending on your needs and free memory.
After editing the PHP-FPM config file restart PHP-FPM
You will be able to view the PHP child process status by typing the following
You can use htop (commands here) to see child PHP processes in the pool and to verify free memory.
This command is good for watching free memory on a server
I prefer to use up free memory (if available) and leave about 100mb free.
Hope this helps someone.
Donate and make this blog better
Ask a question or recommend an article
[contact-form-7 id=”30″ title=”Ask a Question”]
v1.0 Initial Post