What does PHP-FPM do?
PHP FastCGI Process Manager (PHP-FPM) is an alternative FastCGI daemon for PHP that allows a website to handle strenuous loads. It also allows for a host to set specific amounts of resources to process a domain’s requests. PHP-FPM maintains “pools” (workers available to respond to PHP requests) to accomplish this. These “pools” of workers allow the website to handle more requests than it normally could.
PHP-FPM is faster than traditional CGI-based methods, such as SUPHP, for multi-user PHP environments. It does not overload a system’s memory with PHP from Apache processes like
ruid2+php-dso does. This method is useful when a user receives extra traffic that requires resources to process it. For example, your website may receive a spike in traffic after a TV show features it or is linked from a popular website.
You can examine your server, locate the source of the extra traffic, and then enable PHP-FPM on that site via the pool manager. PHP-FPM does this through a service to serve PHP requests that Apache routes traffic to. PHP-FPM only executes PHP requests, which enables it to service content quicker than other methods.
As mentioned, PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites.
These features include:
- Adaptive process spawning (NEW!)
- Basic statistics (ala Apache’s mod_status) (NEW!)
- Advanced process management with graceful stop/start
- Ability to start workers with different uid/gid/chroot/environment and different php.ini (replaces safe_mode)
- Stdout & stderr logging
- Emergency restart in case of accidental opcode cache destruction
- Accelerated upload support
- Support for a “slowlog”
- Enhancements to FastCGI, such as fastcgi_finish_request() – a special function to finish request & flush all data while continuing to do something time-consuming (video converting, stats processing, etc.)
… and much more.
It was not designed with virtual hosting in mind (large amounts of pools) however it can be adapted for any usage model.