Tag Archives: php-fpm

PHP-FPM pool sizes explanation

If you see these settings in a PHP-FPM config. file (real life example):

What does it actually mean?

1) There will never be less than 30 processes (because it starts with 30, and minimum spare is 30)

2) There will always be at least 30 idle processes, except when more than 70 are in use.

3) Idle processes will never be killed off, unless they hit pm.max_requests (because the number of processes cannot possibly exceed the maximum spare)

Too many idle processes is bad, because they use up virtual memory. It is especially bad on a server with no swap, because then they can’t be shunted out of RAM to make room for active processes.
Also, remember that the settings are per-pool. On this particular server, there were three pools with identical settings. The result was that there were never less than 90 PHP processes, even if all were idle.

So please be mindful of the law of unintended consequences, especially when creating additional PHP FPM pools.


Credits to my ex colleague Danny 🙂

Apache 2.2 + PHP-FPM on Centos

WITHOUT disabling MOD_PHP in Apache


One liners alternative for apachebuddy

average apache process mem usage

highest process mem usage cd

php-fpm – www pool average

php-fpm – ALL active pools average memory

MANUAL CHECKS (understanding)

-> RSS is the real memory value
-> VSZ is the one that it might reach (important mostly for MySQL)

# Quicker way is to do top and than press ‘>’

WordPress PHP-FPM and Apache (with variables)

Sample setup for Apache virtual host and PHP-FPM pool with variables instead hard coded user details.
This could be handy if your are scripting your deploy (e.g. with Ansible).

In our example we are using the following:

Domain: example.com
SFTP user: example.com
Document root: /var/www/vhosts/example.com/httpdocs/

Create a file called example.com.conf in /etc/php-fpm/pool/

Apache 2.4 + PHP-FPM Ubuntu 14.04

Create a php-fpm pool /etc/php5/fpm/pool.d/$USER.cnf

In Vhost:

Enable/disable modules and restart services

Don’t forget to enable “index.php” in your DirectoryIndex directive, if using PHP-FPM! Also, remove any PHP directives from Apache, and configure in PHP-FPM instead.

Apache 2.2 + PHP-FPM (Centos 6)

WITHOUT disabling MOD_PHP in Apache

Compile module:

Enable the module:

Install php-fpm and create pools like this:

NOTE: Make sure the path /var/lib/php/session/$USER/ exists and its owned by $USER!

Add this in the VHOST configuration (before the end of </VirtualHost>) )