WordPress PHP Benchmark Comparison – Performance Showdown

PHP Benchmarks

This article is another attempt to keep our readers updated about the latest PHP benchmark for the available PHP versions 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.

Advantages of PHP 7.0 and above versions:

  • PHP 7.0 and above executes your code faster and it also requires fewer servers to serve the same amount of users.
  • Easily handles fatal and catchable fatal errors, hence makes 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 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 implementation of type declaration it becomes easier to read and offers better control on the overall program. For example, you can use 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 was 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 7.1:

  • Void return type has been introduced.
  • Arrays can now be destructured using [ ] syntax in place of list() syntax. list() previously only supported numerical values, now keys can be specified while destructuring.
  • Nullable type can be used as Type Declaration. 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 the performance.
  • You can now handle multiple Exception Types in 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 7.2:

  • You can now type hint the object. Until now only a class could be type hinted.
  • Argon2 can be used as password hash instead of 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 7.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 7.3.

Our focus of the article is to compare the performance of various PHP versions using two very popular and prevalent testing methods. First is 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 which are using PHP 5 for there sites.

PHP Benchmarks version data

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 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 websites. Each of these 10 configurations were 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 test the server’s performance by stressing PHP, MySql and running $wpdb queries.

PHP 5.6 + WordPress 5.2.2

WebPageSpeed test

PHP Benchmark php 5.6

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.

WP Performance Tester Plugin

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 5.6 + WordPress 5.2.2 + WooCommerce

WebPageSpeed test

PHP Benchmark php 5.6 + WooCommerce

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

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 7.0 + WordPress 5.2.2

WebPageSpeed test

PHP Benchmark php 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

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 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

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 7.1 + WordPress 5.2.2

WebPageSpeed test

PHP Benchmark php 7.1 + WooCommerce

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

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 7.1 + WordPress 5.2.2 + WooCommerce

WebPageSpeed test

PHP Benchmark php 7.1 + WooCommerce

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

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 7.2 + WordPress 5.2.2 

WebPageSpeed test

PHP Benchmark php 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

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 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

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 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

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 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

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)

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

Performance Comparisons (WordPress + WooCommerce)

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)

WP Performance Comparisons (WordPress + WooCommerce)

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:

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 *