WordPress PHP Version Benchmark Comparison – Performance Showdown

This article is another attempt to keep our readers updated about the latest PHP benchmark for the available PHP version compatible with WordPress. In this article we will see what each of the available PHP 7 versions and PHP 5.6 have to offer. We analysed each of these versions on the same site and server setup to bring to you the performance test results. We will test these versions with WordPress both with, as well as without WooCommerce.

We keep updating this article with the new updates technology. In previous articles, we compared HHVM with PHP 7.0 and PHP 5 vs PHP 7, where HHVM was good in site speed performance. HHVM is now no more in use with the rise of latest versions of PHP namely 7.1, 7.2 and 7.3 which are already providing better performance results, as HHVM was an unnecessary burden and intermediary process on the performance, which increases the overall load time.

PHP is the most popular coding language which is widely used. It is an open-source general scripting language which makes it appropriate for creating web applications. It can be easily integrated with HTML. It was first developed in 1994, but its new versions are coming with advanced features for better performance and speed. Find how to check PHP version by reading this article

Advantages of PHP version 7.0 and above versions:

 

  • PHP 7.0 and above execute your code faster and it also requires fewer servers to serve the same amount of users.
  • Easily handles fatal and catchable fatal errors hence make the coding and debugging easier.
  • PHP 7.0 is twice as fast as PHP 5.6, and PHP 7.3 is 31% faster than version 7.0.

Let’s take a closer look at what each of these versions offers individually.

What’s new in PHP Version 7.0:

 

  • Better speed: PHP 7.0 code uses less memory and delivers better performance than 5.6, with almost half response time.
  • Type Declaration: With the implementation of type declaration it becomes easier to read and offers better control on the overall program. For example, you can use the Scalar Type declaration for int, float, string, and boolean.
  • Arrays can be defined as Constant in PHP 7.0
  • Error Handling: PHP 7.0 has changed the way errors are handled. Instead of throwing a fatal error and completely stopping the program, it now allows an exception.
  • Introduction of New Operators: Some of the newly introduced operators are Spaceship Operator and Null Coalesce Operator.
  • Cryptographically Secure Pseudo-Random Number Generator: CSPRNG is an API used to generate secure random numbers that can be used to create random passwords.

What’s new in PHP Version 7.1:

 

  • Void return type has been introduced.
  • Arrays can now be destructured using [ ] syntax in place of the list() syntax. list() previously only supported numerical values, now keys can be specified while destructuring.
  • A nullable type can be used as Type Declaration. A null value can be used as a parameter.
  • You can now create a closure from any callable function. It helps in better error handling and improves performance.
  • You can now handle multiple Exception Types in the single catch block. Multiple exceptions are separated using a single ‘pipe’ symbol.
  • Visibility modifiers can be specified for class contacts. Using classes can be made hidden from outside the class.

What’s new in PHP Version 7.2:

 

  • You can now type-hint the object. Until now only a class could be type hinted.
  • Argon2 can be used as a password hash instead of the Bcrypt Algorithm. This makes the passwords more secure.
  • Sodium Library included in core, which is a cross-platform library. It is mainly used for passwords, encryption, decryption, and signatures.
  • Widening of Parameter Type. That means you can skip or override the type hinting without getting an error.
  • Supports trailing comma in multi-line arrays.
  • Abstract method overriding
  • Extension of PDO’s string type to support the national character.
  • Support for Extended Operations has been added to the LDAP extension.
  • The sockets extension in PHP 7.2 is able to lookup address information, and perform actions like connecting, binding, and explaining. The following four functions have been added for this:
    • socket_addrinfo_lookup()
    • socket_addrinfo_connect()
    • socket_addrinfo_bind()
    • socket_addrinfo_explain()
  • EXIF extension now supports larger range of formats including Samsung, DJI, Sony, Minolta, Epson and many more.

What’s new in PHP Version7.3:

This is the latest version of PHP released on 6th December 2018, and it is already gaining a lot of popularity owing to its amazing benefits and features.

Here are some of the major ones:

  • Comes with Flexible Heredoc and Nowdoc Syntaxes. It makes coding faster, as coder’s don’t need to worry about things like putting double quotes on text sentences.
  • Allows a trailing comma in function declarations.
  • Better Handling of JSON errors.
  • Implementation of list() Reference Assignment allows assignment of multiple variables by reference.
  • You will not get an error when attempting to count() something that is not countable, this is possible due to is_countable function.
  • You can now gather the first or the last index of an array without changing its internal state by using newly introduced functions, namely array_key_first() and array_key_last().
  • Enhancement of Argon2 password hash, with Argon2d, Argon2i and Argon2id. Each one of these 3 has its own advantages based on where it has to be used.
  • image2wbmp() function is deprecated from PHP version 7.3.

What’s new in PHP Version7.4:

The latest version of PHP 7.4 has come up with new syntaxes, additional features. The release date is 28th Nov 2019.

Here are some of the major ones:

  • Use of Arrow functions.
  • Performance enhanced with the preloading option.
  • Classes can have properties.
  • Type variance is improved.
  • The null coalescing assignment operator can be used as a shorthand.
  • PHP development enhanced with FFI.
  • Numeric values can be formatted by using underscores.
  • Arrays using the spread operator.

 

Our focus of the article is to compare the performance of various PHP versions using two very popular and prevalent testing methods. For optimum results, you should update the PHP version to the latest. The first is the WebPageSpeed test, and the other is WP Performance Tester Plugin.

PHP Online Usage by Version

According to W3Techs, PHP is used by 79.0% of all the websites whose server-side programming language are recorded there.

Even though WordPress now recommends a minimum PHP version of 5.6, there are still about 61% of websites that are using PHP 5 for there sites.

 

PHP version

Test site details

  • Latest available WordPress version at the time when the article was written WordPress 5.2.2
  • 493 blog posts on the site
  • TwentySixteen default theme
  • 1300+ users
  • Around 800+ comments

Server Details

  • Hosted on an Ubuntu 18.04 server
  • With 1GB Ram
  • 20GB SSD Disk
  • Running Nginx (No caching)
  • Dedicated VPS

Configurations Tested:

 

A total of 10 different configurations were tested by our team. 5 PHP versions were tested with basic WordPress website using the latest WordPress version which is 5.2.2. While the other 5 were tested along with WooCommerce which is the leading plugin for incorporating eCommerce functionality within a WordPress website. Each of these 10 configurations was tested using two different testing tools. So, overall 20 tests were conducted.

TEST 1 : WebPageSpeed test

 

This is a simple web page speed test loading test performed at http://www.webpagetest.org/.

It provides rich diagnostic information that includes resource loading charts, Page Speed optimization checks and suggestions for improvements.

Speed Index is the average time at which visible parts of the page are displayed.

TEST 2 : WP Performance Tester Plugin

For this test we used the “WP Performance tester” plugin, which is a Performance benchmark testing WordPress plugin. This tool tests the server’s performance by stressing PHP, MySql and running $wpdb queries.

PHP Version 5.6 + WordPress 5.2.2

WebPageSpeed test

PHP version 5.6 performance test

Result: The test WordPress website on PHP 5.6, started rendering at 1.7 seconds and loaded completely within 10.795 seconds at a Speed Index of 1.734 seconds.

server Performance Benchmarks

Result: The test WordPress website on PHP 5.6, took a total server execution time of 8.939 seconds, WordPress execution time of 3.053 seconds at a rate of 327.546 queries per second.

PHP Version 5.6 + WordPress 5.2.2 + WooCommerce

WebPageSpeed test

PHP version 5.6 test

Result: The test WordPress website with WooCommerce on PHP 5.6, started rendering at 2.3 seconds and loaded completely within 11.018 seconds at a Speed Index of 2.3 seconds.

WP Performance Tester Plugin

server performance tests

Result: The test WordPress website with WooCommerce on PHP 5.6, took a total server execution time of 8.303 seconds, WordPress execution time of 2.801 seconds at a rate of 357.015 queries per second.

PHP Version 7.0 + WordPress 5.2.2

WebPageSpeed test

PHP version 7.0

Result: The test WordPress website on PHP 7.0, started rendering at 1.3 seconds and loaded completely within 10.421 seconds at a Speed Index of 1.334 seconds.

WP Performance Tester Plugin

PHP version 7.0 performance test

Result: The test WordPress website on PHP 7.0, took a total server execution time of 7.380 seconds, wordpress execution time of 1.994 seconds at a rate of 501.504 queries per second.

PHP Version 7.0 + WordPress 5.2.2 + WooCommerce

WebPageSpeed test

PHP Benchmark php 7.0 + WooCommerce

Result: The test WordPress website with WooCommerce on PHP 7.0, started rendering at 1.8 seconds and loaded completely within 10.529 seconds at a Speed Index of 5.831 seconds.

WP Performance Tester Plugin

PHP 7.0 performance test

Result: The test WordPress website with WooCommerce on PHP 7.0, took a total server execution time of 6.756 seconds, WordPress execution time of 2.230 seconds at a rate of 448.430 queries per second.

PHP Version 7.1 + WordPress 5.2.2

WebPageSpeed test

PHP version 7.1 test

Result: The test WordPress website on PHP 7.1, started rendering at 1.3 seconds and loaded completely within 10.587 seconds at a Speed Index of 1.368 seconds.

WP Performance Tester Plugin

PHP 7.0 test

Result: The test WordPress website on PHP 7.1, took a total server execution time of 6.675 seconds, wordpress execution time of 2.716 seconds at a rate of 368.188 queries per second.

PHP Version 7.1 + WordPress 5.2.2 + WooCommerce

WebPageSpeed test

PHP version 7.1 performance test

Result: The test WordPress website with WooCommerce on PHP 7.1, started rendering at 1.8 seconds and loaded completely within 10.460 seconds at a Speed Index of 5.807 seconds.

WP Performance Tester Plugin

PHP 7.1 performance test

Result: The test WordPress website with WooCommerce on PHP 7.1, took a total server execution time of 6.556 seconds, wordpress execution time of 2.196 seconds at a rate of 455.373 queries per second.

PHP Version7.2 + WordPress 5.2.2 

WebPageSpeed test

PHP version 7.2

Result: The test WordPress website on PHP 7.2, started rendering at 1.8 seconds and loaded completely within 9.492 seconds at a Speed Index of 4.765 seconds.

WP Performance Tester Plugin

test2 php 7 2 wp WordPress PHP Version Benchmark Comparison - Performance Showdown

Result: The test WordPress website on PHP 7.2, took a total server execution time of 6.435 seconds, wordpress execution time of 2.365 seconds at a rate of 422.833 queries per second.

PHP Version 7.2 + WordPress 5.2.2 + WooCommerce

WebPageSpeed test

PHP Benchmark php 7.2 + WooCommerce

Result: The test WordPress website with WooCommerce on PHP 7.2, started rendering at 1.9 seconds and loaded completely within 10.713 seconds at a Speed Index of 5.799 seconds.

WP Performance Tester Plugin

test2 php 7 2 woo WordPress PHP Version Benchmark Comparison - Performance Showdown

Result: The test WordPress website with WooCommerce on PHP 7.2, took a total server execution time of 6.617 seconds, wordpress execution time of 2.276 seconds at a rate of 439.367 queries per second.

PHP Version 7.3 + WordPress 5.2.2

WebPageSpeed test

PHP Benchmark php 7.3

Result: The test WordPress website on PHP 7.3, started rendering at 1.165 seconds and loaded completely within 10.341 seconds at a Speed Index of 1.334 seconds.

WP Performance Tester Plugin

test2 php 7 3 wp WordPress PHP Version Benchmark Comparison - Performance Showdown

Result: The test WordPress website on PHP 7.3, took a total server execution time of 6.258 seconds, WordPress execution time of 1.877 seconds at a rate of 532.766 queries per second.

PHP Version 7.3 + WordPress 5.2.2 + WooCommerce

WebPageSpeed test

PHP Benchmark php 7.3 + WooCommerce

Result: The test WordPress website with WooCommerce on PHP 7.3, started rendering at 1.9 seconds and loaded completely within 10.711 seconds at a Speed Index of 5.722 seconds.

WP Performance Tester Plugin

test2 php 7 3 woo WordPress PHP Version Benchmark Comparison - Performance Showdown

Result: The test WordPress website with WooCommerce on PHP 7.3, took a total server execution time of 6.406 seconds, WordPress execution time of 2.071 seconds at a rate of 482.858 queries per second.

PHP Benchmark Summary

Test 1 : WebPageSpeed test

Performance Comparisons (WordPress Sites)

test1 performance comparison wordpress WordPress PHP Version Benchmark Comparison - Performance Showdown

As evident from the above comparison, 7.2 and 7.3 performs much better than the other older versions.

Performance Comparisons (WordPress + WooCommerce)

test1 performance comparison woocommerce WordPress PHP Version Benchmark Comparison - Performance Showdown

As evident from the above comparison, 7.1 and 7.3 performs much better than the other PHP versions for WordPress sites.

PHP Benchmark WordPress

Graphical Representation of WordPress site on different PHP Versions

TEST 2 : WP Performance Tester Plugin

WP Performance Comparisons (WordPress Sites)

test2 performance comparison wordpress WordPress PHP Version Benchmark Comparison - Performance Showdown

WP Performance Comparisons (WordPress + WooCommerce)

test2 performance comparison woocommerce WordPress PHP Version Benchmark Comparison - Performance Showdown

As evident from the above comparison, 7.2 and 7.3 performs much better than the other older versions.

PHP Benchmark WooCommerce
Graphical Representation of WooCommerce site on different PHP Versions

How to update from PHP 5.6 to PHP 7.3 on Ubuntu 18.04

If you already have PHP 5.6 you can easily upgrade to PHP 7.3. All you have to do is follow the steps below:

It is always recommended to take a backup before changing anything. So, backup everything first.

    • Install PHP 7.3 by installing the package on your server with this command:
    • Add the PHP repository from Ondřej Surý using this command:
    • Update your package list using this command

  • Now the repository is added, to install PHP 7.3 use this command:
  • Check if the installation is successful. Use this command:
  • Now you need to change the default version, use this command to make PHP 7.3 as default version (optional) :
  • If you don’t want to use the older versions you can completely remove them from the server. (Optional).

     

 

How to run 2 PHP versions together on the same ubuntu 18.04 server:

As mentioned in the above section you can install multiple PHP versions on your server, and you will have to set one of them as default. You can use the following set of command to set one of them as default:

Set PHP 7.0 as Default PHP version:

Default version set to PHP 7.2:

Set PHP 7.3 as Default PHP version:

How to install PHP 7.4 on ubuntu 18.04 and 20.04

What do you require?
Setting up Ubuntu server having sudo privileges.
Initial ubuntu server setup should be completed.

If you are tring to install PHP on Google cloud platform, please follow the steps mentioned below.

Step 1: Make sure your ubuntu server is having the latest packages with the help of the following commands.

sudo apt update
sudo apt upgrade

This will help in updating the package index and upgrading the packages which are already installed to the latest version.

Step 2: Next you need to add PPA to your PHP 7.4 version

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

Installing PHP 7.4 version for Apache server

Step 1: After PPA is successfully added, you can go ahead and install PHP 7.4. Use the following command to install.

sudo apt install php7.4

Step 2: Use the following command to Confirm that your PHP 7.4 version is properly installed.

php -v

Installing PHP 7.4 FPM for Nginx

Step 1: For installing on Nginx , you need to first install FPM using the following command.

sudo apt install php7.4-fpm

Step 2: Use the following command to Confirm that your PHP 7.4 version is properly installed.

php-fpm7.4 -v

Installing PHP 7.4 extensions

For installing the PHP extensions, use the following syntax,

sudo apt install php7.4-extension_name

The Verdict

From our tests we found that PHP 7.2 has caught up a lot against the older PHP versions.  But PHP 7.3 has taken a great leap in speed as compared to it’s predecessors. This is because it takes less CPU resources and thus gives a better response time than PHP 7.0.

That being said PHP 7.3’s performance was far better than the older versions in all the tests. PHP 7 also performed better in terms of the number of queries executed per second.

In my opinion, it comes down to what your requirements are. If you are looking for a stable WordPress platform for the future, which performs better than PHP 5.6, then you should go for PHP 7.2 or 7.3. It is no surprise that PHP 7.3 surpasses its performance against HHVM days.

We highly recommend our readers to start switching to PHP 7.2 or 7.3, as PHP 5.6 and 7.0 will be phased out soon completely. And PHP 7.4 is already on its way.

Leave a Reply

Your email address will not be published. Required fields are marked *