FastCGI for PHP is a significant update of the traditional CGI PHP execution mechanism, and it was introduced on our VPS plans back in 2016. Unlike traditional CGI, the FastCGI execution mechanism allows a single process to handle many requests before being terminated. Reducing the overhead of starting a new PHP process with each new request to the web server brings significant speed improvement and lower resource usage. Due to its improved technology, FastCGI improves website loading times and allows more requests to be handled at once. It also supports OPcache - a caching system that further improves PHP performance by keeping pre-compiled script bytecode in the server memory, thus bringing additional speed and resource-usage optimization.
FPM (FastCGI Process Manager) is a newer version of the FastCGI implementation, bringing further improvements to FastCGI, specifically for heavily-loaded sites. PHP-FPM is one of the most efficient and stable technologies for running PHP, and it's currently supported on all our servers - shared hosting servers and VPS. As PHP-FPM uses the FastCGI protocol, it has all the benefits of the FastCGI PHP execution mechanism, but it also maintains the FastCGI workers which handle PHP requests. This results in even faster execution of PHP scripts. If necessary, PHP-FPM will spawn additional workers to handle all incoming requests on time. PHP-FPM comes paired with OPcache by default and uses OPcache resources more efficiently than FastCGI, as the OPcache pool is shared among PHP-FPM child processes.
Here are some of the benefits that FPM has over FastCGI:
- FPM processes requests faster (more than 30%) compared to FastCGI, which also allows it to process more than 30% more requests at a time than FastCGI.
- FPM helps improve visitor experience and search engine ranking due to its 5+ times shorter TTFB (Time To First Byte). This is possible mostly due to the workers being maintained by FPM, while FastCGI has to spawn a new worker if there are no currently active/available workers.
- FPM is supported on all our servers, while FastCGI can be enabled only on certain VPS plans.
- FastCGI can be enabled only manually, while FPM can be enabled with a single click via the Control Panel's PHP Settings section.
- OPcache is enabled by default for FPM; for FastCGI, it has to be enabled manually.
- FPM has better support and is tested more thoroughly by the PHP project.
Since there are no drawbacks of the FPM implementation on our servers compared to the FastCGI implementation, we will gradually stop supporting FastCGI. For this reason, we advise switching to FPM as soon as possible.
Switching from CGI/FastCGI to FPM on our servers is very simple. All you need to do is change the PHP handler for the specific domain/subdomain from CGI to FPM with OPcache via the Control Panel > PHP Settings section. More information on how you can change the PHP handler is available in the PHP version and handler article.
Although this is optional, we would encourage you to revert the steps taken to enable FastCGI in the first place (as outlined in our Using FastCGI + OPcache article) by removing:
- the <IfModule mod_fcgid.c> code block from your website's .htaccess file;
- the .ht-fcgi-php-wrapper file from your website folder;
- the [opcache] code block from the main php.ini file for your website.
Important:The FPM execution mechanism has proven to work correctly with a plethora of web applications; however, we would recommend that your check your website thoroughly for issues after switching the PHP execution mechanism for your website from FastCGI to FPM, as a specific web application or script may be incompatible with FPM. In such a case, please change the PHP execution mechanism for the website to CGI.
If you encounter any problems or need any assistance with the transition from FastCGI to FPM, feel free to contact our support team.