PHP 7 - Time to upgrade

PHP 7 performance gains in WordPress

PHP 7 has been out in a stable, beta format for over a year but usage statistics show that the majority of websites are still running a much older version, usually version 5.6. In this article we look at why this might be and discuss the performance advantages of upgrading.

For many of us with a website what version of PHP it’s running on rarely comes to mind. For WordPress users the chances are that all we really care about is whether the themes and plugins we use are compatible with the version we have. Depending on who your hosting company is it’s very likely you are running PHP 5.6, especially if you have had your hosting account for 6 months or more. So if PHP 7 has been out for a year why should you consider upgrading? Hopefully this article will convince many of you to consider it.

PHP 7 – Why you should look into upgrading.

Firstly let’s get any confusion about the naming out of the way. Most of us who are used to using PHP 5 might be wondering why this version is called PHP 7 and not PHP 6. Well it seems attempts at a PHP 6 had been made down the years but the version never made it out of development and it was considered to be a failure by many. It was decided to pass over PHP 6 and the bad publicity around it and release this new version as PHP 7.

PHP 7 New Features / Improvements

According to statistics released by Zend, the company behind PHP there are some significant performance gains in using PHP 7 for users of many systems, including Magento, Drupal and WordPress. Since WordPress is the CMS I use to build websites I will only concentrate on the improvements WordPress users should expect from upgrading.

In an infographic from Zend it was shown that the number of requests per second possible with PHP 7 had dramatically increased. Using WordPress version 3.6 only 96 requests per second were possible using PHP 5.6 which increased to 204 when using PHP 7. Tests using WordPress version 4.1 revealed 191 requests per second were possible using PHP 5.6 but this jumped to 374 when using PHP 7.

Other tests carried out show that when comparing PHP 7 vs PHP 5.6, the former has much better response times. Using WordPress 4.4.2 PHP 7 had a response time of just 4 milliseconds, far quicker than the 1.2 seconds that PHP 5.6 achieved. In my own tests I was able to improve the reported page loading times in both GT Metrix and Pingdom significantly following the upgrade. With page loading speeds being a Google ranking factor it’s something every website owner should be pleased about.

PHP 7 also makes more efficient use of the CPU. The previous version used around 95 million CPU instructions per WordPress request. With PHP 7 this has reduced to around 26 million instructions. This last point was of particular interest to me because the only weakness of Siteground hosting in my opinion is their restriction on CPU usage time, which is limited to 40,000 seconds per customer each day. Twice before I exceeded this figure and had to carry out various tasks to reduce the load. I won’t go into detail here as it would take too long. In any case I plan to explain more about this in another post since it’s something a number of Siteground customers have experienced. I’m happy to report however that since the update to PHP 7 my CPU usage has dropped by something like 25%.

PHP 7 How Easy Is It to Upgrade?

For many WordPress hosting companies PHP 7 has become the default. This is especially true if you have started a new hosting plan in the last few months. If however you have been with the same hosting company for more than 12 months you should check what version of PHP you are running and whether PHP 7 is available for you to use.

Since I currently use Siteground as my host I will explain the process I had to go through. PHP 7 had been available to Siteground users for about a year. In early December 2016 it became the default version for new customers. For existing customers like myself we had to upgrade if we wanted the latest PHP version. Thankfully with Siteground it’s a very simple process.

My first advice for anyone wanting to upgrade would be to consider the WordPress theme and plugins you use. If you are using a theme or plugins that have not been updated for some time they may not be PHP 7 compatible. If in any doubt you should contact the theme or plugin developer and ask. There is also a plugin that tests your system for compatibility but I was unable to use it as it requires WP-Cron to run which I recently disabled (too resource intensive).

Once you are confident that you can upgrade you need to do the following:

  • login to your account cpanel.
  • Then under the 1H Software section you will see an option called PHP Version Manager. Click this and then navigate to the directory name you want to upgrade (you may have more than one domain on your Siteground account).
  • Select the required PHP version from the drop down list and then click save.

It really is that simple! Before upgrading why not do a site loading speed test before and then again after the upgrade. Also monitor your CPU usage stats, I think you will be pleased with the results of upgrading. So what are you waiting for? If you have a website that runs on PHP I would really recommend looking into upgrading to PHP 7.

Share this post

Leave a Comment

Location

Suite 2, 21 Masefield Way. 
Northampton, NN2 7JT

Our hours

09:00 AM – 17.00 PM
Monday – Friday

Call Us

Telephone:
07513 078341