PHP 7—More BANG for Your Server Buck

Our Experience with PHP 7

PHP 7 was finally released late last year as production ready, making it the first major update to PHP in about 11 years. Since even before it was fully released, InnoScale has been testing and bench-marking PHP 7, in anticipation of widespread deployment. Our validation process for PHP 7 has included compatibility verification with most of the major web application frameworks, especially WordPress, with which we do a lot work. We have also conducted head-to-head bench-marking against the last major point release of PHP, version 5.6, to see how it compares in terms of speed and performance.

Since the release of PHP 7, there have been a lot of claims of version 7 having up to 2x or better performance than the PHP 5.x versions, and we really wanted to see how well that claim held up. We also wanted to make sure we got a good understanding of the changes, so that we can support PHP 7 for our managed clients, such as those clients running high-performance Cloud Clusters.

Load testing: PHP 7 vs. PHP 5.6

For our initial testing, we setup a small distributed stack, with a nginx gateway host in front of a single MariaDB host in the back-end, each with 1 CPU and 1GB of RAM. In the middle, we setup 2 web application hosts, one each running php-fpm with either PHP 7.0 or PHP 5.6. The resources for the web application hosts were scaled up for the testing, from 1 CPU and 1GB of RAM thru 4 CPUs and 8GB of RAM, which are fairly common deployments for our clients.

The nginx host was configured to ‘fastcgi_pass’ to each web application host separately, so we could test them. Also, we made sure that no caching was configured in nginx, to make sure the results were valid for proper testing of PHP performance, and not nginx caching performance. We normally do configure FastCGI caching in nginx for our production environments, as it allows for much faster returns and better performance, especially during traffic surges, but for obvious reasons this was not enabled.

We setup a clean and current installation of WordPress on the stack. To provide some standard test data for the WordPress installation, we imported the test data set provided by http://wptest.io/. It provides a good set of example pages, posts, and categories types.

loadtest

Load generation was performed from an additional host, in front of the nginx gateway, with the tool siege (https://github.com/JoeDog/siege).  This is an excellent tool which we have used for several years now to help stress testing of our production environments and it has proven to be extremely versatile and powerful.

Test Results

Screenshot_2016-08-08_16-26-07

Conclusions

Our results validate the claims of PHP 7 being 2x faster than PHP 5.6.  This is especially borne out as traffic increases, where we were not only able to see faster transaction times with high sustained users for PHP 7 vs. PHP 5.6, but we saw those occurring with lower CPU utilization. This is a rare win-win: Faster page load times on rich content with fewer server resources.

During our extensive testing with WordPresss core and standard plugins, we found no compatibility issues.  There certainly are some plugins which have still not been updated, but almost all of the most popular ones work perfectly under PHP 7 now.

For all new Cloud Clusters, we are going to be using PHP 7 as our default installation base, allowing us to provide much better performance for our clients. We also will work with existing deployments to determine they can be upgraded to PHP 7, since doing so will easily add more performance to existing applications with no changes in resources.  If you are interested in upgrading your installation to PHP 7, please drop us a support request!