Why PHP-FPM?

PHP-FPM not only makes configuration of FastCGI pools, but also enhances some of the FastCGI internals and increases error reporting, script terminiation, etc.

This table has a simple comparison between the most popular methods of managing FastCGI pools.

Description PHP "out of the box" spawn-fcgi + spawn-php.sh + daemontools PHP-FPM
PHP daemonization: pid file, log file, setsid(), setuid(), setgid(), chroot() (-) (+) (+)
Process Management. Ability to "gracefully" stop and start PHP workers without losing any queries. This allows gradually updating the configuration and binary without losing any queries. php4 (-), php5 (only graceful completion) (-) (+)
Restricting IP addresses from which requests can come from php4 (-), php5 (+) (since 5.2.2) (-) (+)
Dynamic number of processes, depending on the load (adaptive process spawning) (-) (-) in SVN, PHP 5.3.3RC1+
Starting the workers with different uid/gid/chroot/environment and different php.ini options. (No need for safe mode.) (-) (-) (+)
Logging stdout and stderr (-) (-) (+)
Ability to emergency restart all the processes in the event of an accidental destruction of the shared memory opcode cache, if using an accelerator (-) (-) (+)
Forcing the completion of process if set_time_limit() fails (-) (-) (+)
Features
Error Header (+)
Accelerated Upload Support (+)
fastcgi_finish_request() (+)
Slowlog (with backtrace) (+)

History

Andrei Nigmatulin is the original author of PHP-FPM. Since 2004, he waited for someone else to make PHP FastCGI production-ready, but he couldn't wait any longer. PHP-FPM is the product of the knowledge, experience and ideas from working with PHP's FastCGI SAPI on several projects.

Since that time, it has evolved into a stable, simple solution to an annoying problem that has not been addressed properly. In mid-2009, Andrei changed the format of PHP-FPM to be more modular, and no longer be a patch that had to be applied against PHP. The source code has been split up from one large patch to a normal set of files. Michael Shadle volunteered to take over the project and work on growing it into a more robust solution. There were a couple major features Andrei was never able to finish, and we're hoping to address those soon - the most important one is adaptive process spawning.

Currently, we're working on making sure that it can be packaged in distributions, the website is clean, consistent and easy to use, and the information is relevant, concise and up to date.

It has recently been brought in to PHP core, thanks to Antony Dovgal, with interim support from Dreamcat4 and continued work from Jérôme Loyet. Andrei's original vision is finally starting to become complete.

Real-world Usage

PHP-FPM serves up millions of PHP requests without an issue for hundreds of websites, with more growing each day. At Open Source Bridge in Portland, Rasmus mentioned he now uses nginx + PHP-FPM at wepay.com, the company he works for. It doesn't get more ratified than that!

License

PHP-FPM is available for public use and licensed under the GPL. The modified version of libevent, which is bundled with PHP-FPM, is distributed under the BSD license.