Comparing WordPress from PHP 5.6 to PHP 8.1

Although at the moment only PHP 8.1 RC2 is still available, without a doubt this new version of PHP is going to give a lot to talk about. This also means that from its release, we will only have as supported versions PHP 7.4 (only with security support), PHP 8.0 and PHP 8.1.

As is already known, Matt made in August 2020 the decision not to comply with the provisions of the roadmap that WordPress 5.6 would stop supporting PHP 5.6 and that it would support PHP 8.0, but one more year has passed and from this WordPress 5.9 it seems that 8 different PHP versions will be supported.

So WordPress 5.9 is going to support the following php versions:

  • PHP 5.6.20+
  • PHP 7.0
  • PHP 7.1
  • PHP 7.2
  • PHP 7.3
  • PHP 7.4
  • PHP 8.0
  • PHP 8.1

Keep in mind that, although WordPress is already compatible with PHP 8.0 and will be compatible with PHP 8.1, the recommended version at the moment is still a version that only has security support: PHP 7.4.

Does WordPress work better with PHP 8.1?

Once again, this study that I propose has little scientific, it is done simply out of curiosity, but I do have to say that the figures, at a comparative level, are correct. What is compared is always the same and with the maximum similarity in configuration (in old PHP versions there are some configurations that have been removed because they are not compatible).

The test, this time, is simply with a content from a Minion Ipsum entry, so it’s simply 4 paragraph blocks in Twenty TwentyOne.

This tutorial has been created on a Clouding.io VPS. You can create your own VPS from 3€/month.

In addition, you have the possibility to create your VPS with the WordPress image in one click.

PARTNERSHIP

A server with 4 CPUs and 8 GB of RAM (and 10 GB of NVMe disk) has been used. Caches have been skipped and JIT has not been configured. I have used a wide configuration so that there are no bottlenecks in either the web server or the database and I am able to eat all the traffic.

The experiment is done on a VPS with Ubuntu 20, with the latest versions of each PHP version available, and with an optimized PHP configuration. So are nginx and MariaDB.

All results have been obtained with the tool “ab”, and “wrk” with the following commands:

ab -n 1024 -c 4 https://example.com/
wrk -c128 -d10s -t1 --latency --timeout 5s https://example.com/

Before each scan the server has been restarted so that it is completely clean and the exact same commands have been executed in the same order as long as the test is as reliable as possible and under the same conditions.

Time to get the test

Time to get 1024 requests, separated into 4 threads.

The lower the value, the better.

PHPTime(s)
PHP 5.615,131
PHP 7.07,517
PHP 7.17,517
PHP 7.27,190
PHP 7.36,816
PHP 7.46,688
PHP 8.06,713
PHP 8.16,441
Data is in seconds (with 3 decimal places)

Requests per second

Requests per second achieved in several tests.

The higher the value, the better.

PHPab (req/s)wrk (req/s)
PHP 5.667,6856,87
PHP 7.0136,23138,32
PHP 7.1136,22137,63
PHP 7.2142,42144,51
PHP 7.3150,24150,10
PHP 7.4153,12156,59
PHP 8.0152,54156,41
PHP 8.1158,98167,30
Data is in requests per second (to 2 decimal places)

Average time of requests

It would become the TTFB (Time To First Byte).

The lower the value, the better.

PHPTime (ms)
PHP 5.659,104
PHP 7.029,363
PHP 7.129,365
PHP 7.228,085
PHP 7.326,624
PHP 7.426,123
PHP 8.026,222
PHP 8.125,161
Data is in milliseconds (to 3 decimal places)

Faster request

Time of the request (of the 1024 made) that has been created faster.

The lower the value, the better.

PHPTime (ms)
PHP 5.651
PHP 7.026
PHP 7.126
PHP 7.224
PHP 7.323
PHP 7.423
PHP 8.023
PHP 8.122
Data is in milliseconds (to 3 decimal places)

Percentile Response Time (ms)

The percentage of requests made has taken less than that time (in milliseconds).

The lower the value, the better.

PHP90% (ms)95% (ms)99% (ms)
PHP 5.6687887
PHP 7.0323337
PHP 7.1323545
PHP 7.2303341
PHP 7.3293137
PHP 7.4282937
PHP 8.0283040
PHP 8.1272937
Data is in milliseconds

Latency distribution

Time it has taken to make the requests (maximum time, 10 seconds) and total requests made in those 10 seconds.

The lower the value, the better.

PHP50% (s)75% (s)90% (s)99% (s)req/10s
PHP 5.64.114.254.344.46571
PHP 7.01.791.811.831.861389
PHP 7.11.771.811.831.871383
PHP 7.21.691.711.731.761450
PHP 7.31.661.691.711.751506
PHP 7.41.561.601.631.671572
PHP 8.01.561.631.681.741569
PHP 8.11.491.511.531.561679
Data is in seconds

Conclusions

As I said at the beginning, it is not scientific data because I have tested it in a fairly simple environment, but it can give a small idea of the improvements that each of the versions suppose.

  • PHP 8.1 could bring a speed improvement of 5-7% over PHP 8.0.
  • PHP 8.1 goes 3 times faster than PHP 5.6
  • Regarding PHP 5.6
    • PHP 7.3 goes 2.63 times faster
    • PHP 7.4 goes 2.73 times faster
    • PHP 8.0 goes 2.74 times faster
    • PHP 8.1 goes 2.94 times faster

About this document

This document is regulated by the EUPL v1.2 license, published in WP SysAdmin and created by Javier Casares. Please, if you use this content in your website, your presentation or any material you distribute, remember to mention this site or its author, and having to put the material you create under EUPL license.

6 thoughts on “Comparing WordPress from PHP 5.6 to PHP 8.1”

  1. Hola Javier
    gracias por tanto que das
    queria preguntarte si ¿es seguro pasar a PHP 8.0 ?
    tanto una web relativamente sencilla como un Woocommerce con muchos productos
    saludos

  2. Es seguro siempre y cuando todos tus plugins sean compatibles. En general PHP 8.0 debería ser compatible con todo lo que hay ya en WordPress…

    Depende de tu hosting, si te permite cambiar fácilmente entre una versión y otra, es cuestión de probarlo, aunque lo ideal sería hacerlo con una versiónd e staging.

  3. Javier, sería bien interesante que comparas PHP 8, con JIT activo, eso en teoría debería mejorar sustancialmente (más de 50%) la velocidad de respuesta.

  4. En el caso de WordPress, JIT no aporta mucha cosa… ya hice la prueba el ño pasado y los cambios no son significativos (como digo, en WordPress).

  5. Ahora mismo sí… WordPress no está adaptado todavía para aprovechar PHP 8.0 y mucho menos PHP 8.1, por eso aún se recomienda el uso en producción de PHP 7.4 y, por ejemplo, MariaDB 10.5 (aunque el soporte oficial es hasta MariaDB 10.3)

Comments are closed.