X
    Categories: Cloudways News and Updates

PHP-FPM Cuts Web App Loading Times by 300%

Speed matters. Our engineers are always looking at ways on improving the stack. One of the major objectives of our stack integrations is to improve the speed of the overall processes of our stack.

Keeping up with this practice, in a bid to increase speed of aspects of Managed Cloud Hosting coupled with constant improvements based on users feedback, Cloudways has now integrated PHP-FPM in all its servers. Owing to this integration, applications hosted on Cloudways servers are now going to perform up to 3x faster.

Why PHP-FPM?

From a website visitor’s perspective, switching from mod_PHP to PHP-FPM might not be much of a bigger deal. However, from a system administrator’s point of view, both of these are entirely different things.

All system administrators are aware that PHP works with all major web servers and it can be run in different ways on your server. One of the most common known ways to run PHP is the mod_php module. This is because it comes by default on the Apache HTTP servers. But there is a slight problem. Unlike PHP-FPM, mod_PHP locks out processes and disrupts the performance of a website.

If your primary goal for hosting your web application with an optimized cloud service is to achieve optimal performance and security, then PHP-FPM is the way forward.

PHP-FPM (FastCGI Process Manager) dramatically speeds up the performance of your PHP environment.

PHP-FPM vs. mod_PHP Performance Benchmarks

Using a controlled environment we tested a WordPress website using both PHP-FPM and mod_PHP. We have not used Varnish or Turpentine for the test. Each time, we noticed increased performance and stability with the stack that contained PHP-FPM.

Performance with mod_PHP

We used a DigitalOcean 4 GB server. The app for this test was a WordPress website.

Test generated 38,046 successful hits in 295.0 seconds with a data transfer of 7,399.11 KB in and 206,219.42 KB out from the app. The average hit rate of 128.0/second translates to about 1,1059,200 hits/day.

The average response time was 2150 ms.

Performance with PHP-FPM

The only thing different in this test is the addition of PHP-FPM.

Test generated 85,829 successful hits in 295.0 seconds with a transfer of 16,465.18 KB in and 465,728.74 KB of data out from the app. The average hit rate of 290.0/second translates to about 25,056,000 hits/day.

The average response time was 628 ms.

Results

You can notice PHP-FPM made our test website almost 350% faster when it comes to loading times. Plus, it made the site twice as resource efficient as it was with mod_php.

PHP-FPM, one of the newest way to use PHP in conjunction with a web server, is an alternative PHP FastCGI implementation. This module of PHP can be used with any web server which is compatible with the protocol of FastCGI.

The major advantage of PHP-FPM is that it relies on the concept of pool management. Each pool of PHP-FPM can be viewed as a full instance of PHP, having a configuration, limit and restrictions of its own. These limitations, restrictions, and configurations are in terms of the child processes, modules, environment variables, folders, and logs.

How to Enable PHP-FPM?

For servers launched after this announcement dated August 23rd, 2016, PHP-FPM has been enabled by default. For new server instances, mod_PHP has been retired by default. For servers launched before August 23rd, you can enable PHP-FPM by going over this step-by-step guide.

PHP-FPM vs. mod_PHP: Which is Better?

We believe that it is really not a matter of PHP-FPM vs mod_PHP. With this move, we are targeting the main aspects Cloudways aspires to achieve: Reliability, Security, Scalability, and Speed. PHP-FPM provides all these along with a lot of customization and performance tuning opportunities. Therefore, it is only feasible that we move from slower processes (mod_PHP) to much faster processes with PHP-FPM.

Immad Uddin Khan: Immad is a Digital Content Producer for Cloudways - A Managed Cloud Hosting Platform. He is mostly busy in creating all sorts of informative and innovative content types. As a hobby, he loves to travel with his camera to picturesque destinations.