
Inspired by a recent benchmark test published by Kinsta, I looked up SiteGround’s handy guide to enabling PHP 7. Kinsta’s tests showed that HHVM is faster than PHP 7, but that PHP 7 is still about 3x faster than PHP 5.6.
No, there is not a PHP 6, even though books were published about it. If this kind of thing interests you, you can read why. The TL;DR is that the PHP team messed up PHP 6 so badly they had to scrap it all and start over. I have to wonder if this is also why we went from Windows 8 to Windows 10. (Though I’m using Windows 7 at the time of writing, I’m expecting to upgrade to 10 at some point after I replace my overfull SSD with a bigger one.)
I can get PHP 7 on my SiteGround GoGeek account at no extra charge, but to get HHVM I would need a much more expensive class of hosting. Plus, Jason Cosper’s talk at WordCamp Sacramento suggested that some tests have found PHP 7 to perform better than HHVM. Making this website three times faster sounded good to me.
The first thing to do, as a SiteGround customer, is update the SG Cache plugin to the most recent version, and then disable and re-enable Memcached. I did that both from the plugin end and the control panel end, just to be sure.
Next, I located the PHP Version Manager. It’s in the 1H Software group.
This allowed me to choose the directories I wanted to apply my PHP version changes to. Since I didn’t want to risk breaking everything at once, I just selected the folder for the WP Fangirl site and set it to PHP 7. (Why anyone would want to set their site back to PHP 4.4.9, I have no idea.)
Just choose your version and click “Save”–that’s it. In this case, there were no problems. I hadn’t expected there to be, since the site is fairly new and everything is up to date.
Naturally I wanted to know how much faster my site was. I had cleverly run a GTMetrix test on the site while it was still on PHP 5.6, with the following results:
And this, mind you, was with caching enabled and after I’d used the WP Performance Score Booster plugin to fix some of the problems that showed up the first time I ran GTMetrix a month or so ago. The thing that brings the score down to a C is not serving scaled images, and I’m hoping that once I create some new image sizes to work with the new responsive images feature in WordPress 4.4, that will improve. What we’re really looking at here, though, is the page load time: 5 seconds. In other words, much too slow.
After I switched to PHP 7, I got the following results:
Page load time definitely improved, though it was not 3 times faster. Still, cutting 1.2 seconds off the page load time with one simple change was definitely worth the brief time it took me to enable PHP 7.
I decided to do a little additional tinkering, and replaced WP Performance Score Booster with WP Rocket. (We now have a developer license for wp Rocket, so I am becoming quite profligate with it.) I had to tinker with the settings a bit, but was able to get page load time down to 3.0 seconds.
Yes, for all those who might have been wondering: WP Rocket is compatible with SiteGround’s caching. They even put that in their documentation. And it’s compatible with CloudFlare, too. If you give it your CloudFlare API key, you can clear the CloudFlare cache or set CloudFlare to developer mode from within the WP Rocket settings.
Note that you can’t use WP Rocket along with WP Performance Score Booster. WP Rocket warns you of that when you install it. But the only thing that WP Performance Score Booster does that WP Rocket doesn’t is remove query strings from URLs, and WP Rocket has an explanation for why they don’t do that.
In conclusion: I definitely recommend switching to PHP 7 as long as nothing breaks when you do it. You may not triple your site speed, but there will be observable performance improvements. Oh, and I love the way SiteGround stays on top of new technology.
Page load time is not the same as PHP execution time, you can’t really expect 3x page load even though PHP is running 3x faster.
Saving 35% page load just with a version change is HUGE. I’d be very happy with that change, congrats.
Thanks for the clarification, and yes, I was happy. Do you know of any tools to measure PHP execution time? Though I’m not sure I want to switch back to PHP 5.6 just to run a test.
I saw on this blog post that PHP 7 running on WordPress 4.4.2 has response time of 4ms compared to 1.2s for PHP 5.5. This is quite an improvement over previous versions and much better than HHVM benchmarks. Here is the blog post I was talking about: http://www.cloudways.com/blog/turbocharge-your-cloud-based-application-with-php-7/
Is there any changes I might need to make to the themes or is it fairly safe to assume they’ll all work with php7 fine?
It depends on your theme and plugins, Sam. In most cases, if the developers have kept them up to date, they should be fine. But sometimes you’ll run into an error. If your hosting company allows you to change PHP versions easily, you can revert to PHP 5.6 if you run into problems. And of course you should make a backup of your site before you try out PHP 7.
If you get an error, check to see where it’s coming from and get in touch with the developer of that plugin or theme. S/he may be able to update it for you so you can upgrade to PHP 7 safely.