What is PHP-FPM? A PHP for high traffic websites

PHP-FPM

PHP-FPM (FastCGI Process Manager) is the most popular alternative implementation of PHP FastCGI. PHP (acronym of PHP: Hypertext Preprocessor) is one of the most popular open source programming languages on the Internet, used for web development in platforms such as Magento, WordPress or Drupal. Although it was initially designed for preprocessing plain text in UTF-8.

PHP, created by Rasmus Lerdorf in 1995, was one of the first languages that could be included in HTML code, without having to call external files. This general-purpose scripting language on the server side has constantly evolved so that it can be supported by any operating system or web platform. Furthermore, PHP keeps evolving and is published under the PHP licence, which is incompatible with the GNU General Public License due to use restrictions of the PHP term. 

What is PHP-FPM and its features

PHP-FPM is the most popular alternative implementation of PHP FastCGI. It has additional features which are really useful for high-traffic websites. These are some of them:

  • Advanced management that enables to easily stop/start processes.
  • Possibility to start workers with different uid/gid/chroot/environment and diverse php.ini; it replaces safe_mode.
  • Stdout and stderr logging.
  • Emergency restart in case of accidental destruction of the opcode cache.
  • Accelerated support for uploads.
  • Slowlog variable configuration; to detect which functions take a longer time to execute than usual.
  • Based on php.ini configuration files.
  • FastCGI improvements, as fastcgi_finish_request(); a special function to stop and download all data while you keep doing a longer process such as video conversions or statistics processing.
  • Basic statistics (similar to Apache’s mod_status module). NEW! 

Nginx and PHP-FPM: a perfect match

Nginx, as a stable high-performance web server and with a very low consumption of resources, is the perfect match for PHP-FPM. Nginx has an asynchronous architecture that is much more scalable, based on events. Moreover, when using Nginx with PHP-FPM, performance at the level of memory consumption is improved.

PHP runs as a separated service when using PHP-FPM. By using this PHP version as language interpreter, requests are processed through a TCP/IP socket; so that the Nginx web server only handles the HTTP requests and PHP-FPM interprets the PHP code. The fact of having two separate services is key for increasing efficiency.

HHVM: a former alternative to PHP-FPM

Currently, HHVM is no longer in use. With the arrival of the last PHP version together with FPM, the performance of this language has been equaled, or even improved, without the need of using HHVM — compatible with most of the functions of PHP 7.

Until the arrival of PHP 7, the PHP HHVM processor developed by Facebook and released on GitHub with PHP and Zend licences was often used. HHVM (HipHop Virtual Machine) is an open source virtual machine based on the JIT (Just-in-Time) compiler, which serves as an execution engine for PHP and Hack.

By using the JIT compiler principle, HHVM executes PHP or Hack code in intermediate Bytecode HipHop code; a code which is later translated into machine code, natively optimized and executed. This contrasts with the usual interpreted execution of PHP where the Zend Engine transforms PHP source code into opcode (bytecode form); which is executed by the virtual CPU of Zend Engine.

PHP 7 and future versions of PHP

The arrival of PHP 7 involved a great increase in performance compared to previous versions of PHP. This made that applications such as HHVM, which were used to accelerate services, fell into disuse. In this PHP comparator, you can view the differences among the diverse versions of PHP for several applications. The comparative chart shows how performance has been almost doubled since PHP 5.

For the next major version, PHP 8, the development seems to be focused on creating new functionalities instead of considerably improving speed. So, in order to avoid the application to stop working after the update, the compatibility between the applications and the changes included in the new version must be considered when updating.

WordPress with PHP-FPM

If you have a content platform, online newspaper or, simply, a WordPress that needs high performance and receives thousands or millions of visits, it is evident that you need a Nginx server with PHP-FPM support. This will allow you to set up the execution of PHP code of your WordPress CMS much more efficiently

Magento with PHP-FPM

The eCommerce platform Magento also integrates well with Nginx and PHP-FPM. In fact, in order to achieve the best performance in your online store, apart from using balancers and caches, it is key to use this popular web server together with support for PHP-FPM.

Stackscale can help you with infrastructure and Private Cloud solutions; as well as with system administration.

Share it on Social Media!

Cookies customization
Stackscale, Grupo Aire logo

By allowing cookies, you voluntarily agree to the processing of your data. This also includes, for a limited period of time, your consent in accordance with the Article 49 (1) (a) GDPR in regard to the processing of data outside the EEA, for instead, in the USA. In these countries, despite the careful selection and obligation of service providers, the European high level of data protection cannot be guaranteed.

In case of the data being transferred to the USA, there is, for instance, the risk of USA authorities processing that data for control and supervision purposes without having effective legal resources available or without being able to enforce all the rights of the interested party. You can revoke your consent at any moment.

Necessary Cookies

Necessary cookies help make a web page usable by activating basic functions such as the page navigation and the access to secure areas in the web page. The web page will not be able to work properly without these cookies. We inform you about the possibility to set up your browser in order to block or alert about these cookies, however, it is possible that certain areas of the web page do not work. These cookies do not store any personal data.

- moove_gdpr_popup

 

Analytical cookies

Analytical cookies allow its Editor to track and analyze the websites’ users behavior. The information collected through this type of cookie is used for measuring the activity on websites, applications or platforms, as well as for building user navigation profiles for said websites, application or platform, in order to implement improvements based on the analysis of data on the usage of the service by users.

Google Analytics: It registers a single identification used to generate statistical data about how the visitor uses the website. The data generated by the cookie about the usage of this website is generally transferred to a Google server in the USA and stored there by Google LLC, 1600 Amphitheatre Parkway Mountain View, CA 94043, USA.

- _dc_gtm_UA-XXXXXXXX-X

- _gat_gtag_UA_XXXXXXXX_X

- _ga

- _gcl_au

- _gid