[00:00]
With every new release of PHP, you
[00:02]
probably ask yourself, is there an
[00:04]
automatic gain in performance just by
[00:07]
upgrading? This is what I asked myself
[00:09]
when PHP 8.4 came out and put my team at
[00:12]
Tideways to work on a benchmark to
[00:14]
answer once and for all. The results are
[00:17]
now published on our blog, and I want to
[00:20]
discuss them in this video. The main
[00:22]
result, upgrading to PHP 8.4 four will
[00:26]
not magically increase the performance
[00:28]
of your PHP application to noticeably
[00:31]
better
[00:32]
levels. In fact, our benchmarks show
[00:35]
that during the PHP8 series, not a
[00:38]
single release improved the performance
[00:41]
noticeably. That means PHP 8.4, 8.3, 8.2
[00:45]
are almost virtually the same
[00:48]
performance. This was quite a surprise
[00:50]
to me. The reason is that previous
[00:53]
benchmarks by others showed that there
[00:57]
was a noticeable small improvement
[00:59]
across uh the different
[01:02]
versions. Specifically, this uh PHP
[01:05]
benchmarks post that was widely cited
[01:08]
across the community showed increases of
[01:12]
a few% between uh the different PHP 8.1,
[01:16]
8.2, and 8.3 versions.
[01:18]
In our benchmark, we were not able to
[01:20]
replicate these improvements. For our
[01:23]
benchmark, we set up two test scenarios
[01:25]
that each ran for 60 seconds, including
[01:28]
warm-up periods. First, we measured the
[01:31]
response times by sending a fixed number
[01:35]
of
[01:36]
requests. Second, we measured the
[01:38]
requests per second by sending as many
[01:41]
requests as possible during the time
[01:43]
period.
[01:45]
We did this against three widely spread
[01:48]
frameworks. A Symfony demo application,
[01:51]
a Laravel demo application, and a
[01:53]
WordPress demo application. You can find
[01:56]
more details on our methodology on the
[01:58]
blog post, including the code to set up
[02:00]
the benchmarks, uh the specifications of
[02:03]
the machine we used and the versions of
[02:06]
all the different software that we
[02:07]
benchmarked against. Let's look at the
[02:10]
results starting with
[02:12]
Symfony. As you can see, for the tests
[02:15]
sending 100 requests per second, the
[02:18]
response times across the versions PHP
[02:20]
8.2, 8.3, and 8.4 did not noticeably
[02:25]
change. The average median 95, and 99
[02:29]
percentile are virtually the same.
[02:31]
Looking at the test with 15 concurrent
[02:34]
users attempting to send as many
[02:36]
requests as possible, we also see that
[02:38]
for PHP 8.2, 8.3, and 8.4, for the
[02:42]
number of requests is almost the same at
[02:47]
538. We see the similar results for the
[02:50]
Laravel demo application across PHP 8.2
[02:53]
to 8.4 for all the metrics average
[02:56]
median 195 and 99 percentile. The
[03:00]
response times are almost the same
[03:02]
signaling that the performance did not
[03:04]
really change for the test sending as
[03:07]
many requests as possible for 60
[03:09]
seconds. The Laravel demo application
[03:12]
achieved around 1,020 requests per
[03:15]
second regardless of the PHP version
[03:18]
8.2, 8.3 or 8.4. So the performance here
[03:22]
again almost the
[03:26]
same. We also picked WordPress because
[03:29]
it's possible to install it on such a
[03:32]
wide range of PHP versions that we are
[03:35]
able to test it from PHP 7.4 to
[03:38]
8.4. Again, throughout the PHP8 series,
[03:42]
there's not really a visible change in
[03:44]
performance. However, from PHP 7.4, it
[03:48]
seems the performance increased slightly
[03:51]
to
[03:52]
PHP8. We can see this here that the
[03:55]
response times for 100 requests per
[03:57]
second slightly decreased by a few
[04:00]
milliseconds from uh PHP 7.4 to uh 8.2
[04:04]
and following versions.
[04:09]
This change is much more visible for the
[04:12]
scenario where we send 15 concurrent
[04:15]
users to uh perform as many requests as
[04:17]
possible for 60 seconds. For PHP 7.4,
[04:21]
the WordPress installation achieved 206
[04:25]
requests per second and a 5% roughly 5%
[04:29]
higher number for all the PHP 8.2, 8.3,
[04:33]
and 8.4 four versions with around 220
[04:37]
requests. This at least shows that there
[04:39]
is some improvement from PHP 7 to PHP 8,
[04:43]
but it also cements that the performance
[04:46]
in P the PHP8 series really didn't
[04:49]
change a lot just by upgrading the
[04:51]
version. With these results, I ask
[04:54]
myself what the future for PHP
[04:56]
performance holds.
[04:58]
First, the Zen virtual machine seems to
[05:00]
be at the end of the potential
[05:02]
improvements that we see. The next
[05:05]
versions will not radically increase the
[05:07]
performance anymore. Second, we can see
[05:11]
improvements in specific PHP APIs across
[05:14]
the latest versions. So, for example,
[05:17]
the new DOM document HTML 5 support has
[05:20]
a lot of performance improvements. We
[05:23]
have the sprintf improvements and also
[05:25]
improvements to various APIs and
[05:27]
functions. So if you want to invest some
[05:30]
time in your application, you can
[05:32]
improve it the performance by using more
[05:35]
modern and faster
[05:37]
APIs. Third, we haven't really seen much
[05:41]
performance improvements by the just in
[05:43]
time compiler that uh PHP now has for
[05:46]
web applications. the performance
[05:48]
difference is really not measurable and
[05:50]
we will see if there's maybe an
[05:52]
improvement to the uh JIT in the future
[05:54]
that will level up the performance of
[05:56]
PHP to a new level. In conclusion, your
[06:00]
application architecture, code, and
[06:02]
algorithms are probably the most
[06:04]
important puzzle piece in improving the
[06:07]
performance of your application going
[06:09]
forward. You can find a few ideas on how
[06:12]
to improve PHP performance on this
[06:13]
YouTube channel, and we'll add a new
[06:15]
video every week. Don't miss out by
[06:18]
subscribing to this channel. See you
[06:20]
around. Bye.