Increase your Drupal 7 site speed with PHP 7
PHP has spent many years in the 5.x era, moving through point releases and incremental functionality changes. There was an attempt at a large unicode rewrite for PHP 6 that never got too far off the ground and we’ve just kept trucking along on PHP 5.
We’ve now skipped right past PHP 6 and on to PHP 7, which has focused almost exclusively on performance, with some very dramatic improvements. Many benchmarks have been touting a 2x speed increase, and some initial benchmarks on Drupal 8 and other PHP platforms have shown that to be true. What about Drupal 7 though? For lots of people a Drupal 8 upgrade is a long way off. PHP 7 is largely backwards compatible with PHP 5, so making Drupal 7 work on it is not out of the question. Just recently Drupal 7 achieved 100% passing test coverage on PHP 7 and I figured we should run it through some benchmarks to test performance.
Not technical? Click here to learn how faster websites make more money.
As you can see in the chart above, the improvements are even greater than expected, with average response times 2.5x quicker on a standard Drupal install and 3x quicker on a standard Drupal Commerce Kickstart install.
For the above benchmarks, I ran the following setup:
- Stock Ubuntu 14.04 nginx setup on an AWS t2.small instance
- Both setups are identical except for the PHP version.
- I used Apache Bench for the tests, running 1000 requests at 10 concurrency
ab -n 1000 -c 10 http://mydomain.com/
I ran the tests multiple times to ensure consistent results and also ran them with different concurrency settings, which produced different times but the same ratio between PHP5 and PHP7.
Some cursory results also show it using about half the amount of memory, but I’d like to profile that a bit more accurately before I feel totally confident in those results.
Drupal 7 and Drupal Commerce 1.x are quite new to running on PHP7, so use them with caution, but with such drastic speed improvements, it seems very easily worth the risk.