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.
PHP | Time(s) |
---|---|
PHP 5.6 | 15,131 |
PHP 7.0 | 7,517 |
PHP 7.1 | 7,517 |
PHP 7.2 | 7,190 |
PHP 7.3 | 6,816 |
PHP 7.4 | 6,688 |
PHP 8.0 | 6,713 |
PHP 8.1 | 6,441 |
Requests per second
Requests per second achieved in several tests.
The higher the value, the better.
PHP | ab (req/s) | wrk (req/s) |
---|---|---|
PHP 5.6 | 67,68 | 56,87 |
PHP 7.0 | 136,23 | 138,32 |
PHP 7.1 | 136,22 | 137,63 |
PHP 7.2 | 142,42 | 144,51 |
PHP 7.3 | 150,24 | 150,10 |
PHP 7.4 | 153,12 | 156,59 |
PHP 8.0 | 152,54 | 156,41 |
PHP 8.1 | 158,98 | 167,30 |
Average time of requests
It would become the TTFB (Time To First Byte).
The lower the value, the better.
PHP | Time (ms) |
---|---|
PHP 5.6 | 59,104 |
PHP 7.0 | 29,363 |
PHP 7.1 | 29,365 |
PHP 7.2 | 28,085 |
PHP 7.3 | 26,624 |
PHP 7.4 | 26,123 |
PHP 8.0 | 26,222 |
PHP 8.1 | 25,161 |
Faster request
Time of the request (of the 1024 made) that has been created faster.
The lower the value, the better.
PHP | Time (ms) |
---|---|
PHP 5.6 | 51 |
PHP 7.0 | 26 |
PHP 7.1 | 26 |
PHP 7.2 | 24 |
PHP 7.3 | 23 |
PHP 7.4 | 23 |
PHP 8.0 | 23 |
PHP 8.1 | 22 |
Percentile Response Time (ms)
The percentage of requests made has taken less than that time (in milliseconds).
The lower the value, the better.
PHP | 90% (ms) | 95% (ms) | 99% (ms) |
---|---|---|---|
PHP 5.6 | 68 | 78 | 87 |
PHP 7.0 | 32 | 33 | 37 |
PHP 7.1 | 32 | 35 | 45 |
PHP 7.2 | 30 | 33 | 41 |
PHP 7.3 | 29 | 31 | 37 |
PHP 7.4 | 28 | 29 | 37 |
PHP 8.0 | 28 | 30 | 40 |
PHP 8.1 | 27 | 29 | 37 |
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.
PHP | 50% (s) | 75% (s) | 90% (s) | 99% (s) | req/10s |
---|---|---|---|---|---|
PHP 5.6 | 4.11 | 4.25 | 4.34 | 4.46 | 571 |
PHP 7.0 | 1.79 | 1.81 | 1.83 | 1.86 | 1389 |
PHP 7.1 | 1.77 | 1.81 | 1.83 | 1.87 | 1383 |
PHP 7.2 | 1.69 | 1.71 | 1.73 | 1.76 | 1450 |
PHP 7.3 | 1.66 | 1.69 | 1.71 | 1.75 | 1506 |
PHP 7.4 | 1.56 | 1.60 | 1.63 | 1.67 | 1572 |
PHP 8.0 | 1.56 | 1.63 | 1.68 | 1.74 | 1569 |
PHP 8.1 | 1.49 | 1.51 | 1.53 | 1.56 | 1679 |
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.
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
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.
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.
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).
Por lo que veo en la mayoría de pruebas la versión 7.4 es ligeramente mejor que la 8.0, a pesar de ser una versión superior.
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)