[00:00]
PHP 8.5 was just released last week and
[00:03]
naturally you are as curious as I am if
[00:06]
it's faster than previous versions of
[00:08]
PHP. My colleague Tim set out to test
[00:12]
this with a benchmark for PHP 8.4 and
[00:15]
comparing a Symfony Laravel and a
[00:17]
WordPress demo applications against
[00:19]
previous versions of PHP.
[00:22]
Can you expect a big performance
[00:24]
increase like from PHP 5 to 7 or is
[00:28]
there no noticeable increase? In this
[00:30]
video, I'm going to discuss our
[00:32]
findings. Mo, I am Benjamin and my team
[00:36]
and I work on PHP performance 24/7 for
[00:39]
the last 10 years, helping thousands of
[00:41]
developers along the way. Let's start
[00:43]
discussing the benchmark results that
[00:45]
Tim collected. You find all of them in
[00:47]
our blog post. The link is in the
[00:49]
description. First, the setup is always
[00:52]
important. Uh the blog post lists
[00:54]
everything that went into this
[00:56]
benchmark. So, first you will find all
[00:58]
the code that we use for infrastructure
[01:00]
provisioning and the demo applications.
[01:03]
We used a Hetsa machine with eight
[01:05]
dedicated virtual cores. We are using uh
[01:08]
the Debian 13 Trixie release uh for a
[01:12]
database MySQL or SQLite depending on
[01:14]
the demo. And the uh one important
[01:17]
factor is for PHP we used um the suri um
[01:22]
packages built for Debian um including
[01:26]
PHP 8.5 release candidate number three
[01:30]
for the PHP setup we didn't change a lot
[01:34]
uh the JIT is not enabled and uh PHP FPM
[01:37]
is configured with a static pool of 17
[01:40]
workers.
[01:42]
The for the project versions we have
[01:44]
Laravel version 12, Symphfony 7.3,
[01:47]
WordPress 6.8 and we used Va for um uh
[01:51]
doing performing the benchmark testing.
[01:53]
As for our methodology, what we ran here
[01:56]
is two different kinds of benchmarks. So
[01:59]
we tested with a fixed request per
[02:02]
second number so that we can focus on
[02:04]
the response time of PHP um with this
[02:07]
fixed number of requests. And the second
[02:10]
test we did is with a fixed level of
[02:12]
concurrency to focus on the sort of
[02:16]
throughput. How many requests per second
[02:19]
did we achieve by running this fixed
[02:21]
level of concurrency. Uh both tests run
[02:24]
for about 60 seconds or for 60 seconds
[02:27]
and then we compile these numbers and uh
[02:30]
generate charts from them.
[02:33]
We try to make the test setup as simple
[02:36]
as possible because we usually expect
[02:38]
that you don't reconfigure PHP too um
[02:43]
broadly. So what we didn't want to test
[02:46]
is um PHP versions that are
[02:49]
self-compiled or um use very complex
[02:53]
setup of the demo applications or PHP
[02:55]
itself because from experience
[02:58]
um 95% of you will be running PHP on um
[03:02]
more vanilla uh configurations the
[03:05]
default configurations.
[03:07]
So um we wanted to replicate this kind
[03:10]
of running PHP. Let's go through the
[03:12]
results one by one. We are starting with
[03:15]
Symfony and we are looking at the test
[03:18]
scenario where we run 100 requests per
[03:21]
second a fixed number of requests every
[03:23]
second and then we are looking at uh the
[03:26]
response times that we see from the uh
[03:28]
demo application. So for a symfony
[03:31]
application we can see across versions
[03:34]
PHP 8.2 2 to 8.5 that the response times
[03:39]
are slightly slower for PHP 8.5 compared
[03:43]
to 8.2 or 8.3 for example in the mean.
[03:47]
Uh also like super slightly slower in
[03:51]
the median 95 percentile and 99
[03:54]
percentile.
[03:56]
This is not statistically
[03:59]
uh significant. So um it is within the
[04:02]
margin of error. um the numbers could
[04:05]
statistically be the same. So there's
[04:08]
really no difference in the performance
[04:10]
between these versions if we um perform
[04:13]
this kind of test where we run a fixed
[04:15]
number of requests um against the
[04:17]
Symfony application every second. For
[04:19]
the second test for Symfony uh running
[04:22]
15 concurrent users to find out how many
[04:24]
requests is the application being able
[04:27]
to process in a fixed time frame. we see
[04:30]
there um across all PHP versions it's
[04:33]
around 500 requests and uh again it's
[04:36]
within the margin of error so um it's
[04:39]
not clear which version here is faster
[04:41]
or not they all seem to be equally fast
[04:44]
same for the Laravel case uh first for
[04:47]
the test with 100 requests per second uh
[04:51]
testing the response time we can see uh
[04:54]
in the mean median 95 and 99 percentile
[04:58]
are roughly the same there seems to be
[05:00]
one outlier for PHP 8.3 in the 99th
[05:03]
percentile but this is also not very big
[05:07]
and um selfcorrected itself in the next
[05:10]
so in PHP 8.3 so in general again here I
[05:14]
would say the performance for PHP 8.5 is
[05:17]
the same than the previous versions 82
[05:20]
to 8.4 for for Laravel case with the
[05:24]
scenario of 15 concurrent users making
[05:27]
as many requests as possible in 60
[05:29]
seconds. We can also see here around 850
[05:33]
requests for this Laravel demo
[05:35]
application and it's the same uh
[05:37]
regardless of the PHP version. So again
[05:40]
it doesn't seem to be that PHP 8.5 is
[05:43]
generally faster than previous versions.
[05:46]
As a third case, we've took WordPress um
[05:49]
specifically also because it's possible
[05:52]
to run WordPress still with PHP 7.4. So
[05:56]
here we can test is there a performance
[05:58]
difference between PHP 7.4 and all the
[06:02]
PHP 8 versions including 8.5. And for
[06:05]
the test with 100 requests per second,
[06:08]
we can see the performance is not really
[06:12]
um very different between these
[06:14]
versions. um there is within the margin
[06:18]
of error no real um improvement between
[06:21]
all these versions.
[06:24]
So we can conclude that PHP 8.5 is also
[06:28]
not faster for WordPress applications
[06:31]
compared to previous versions. For a
[06:33]
test with 15 concurrent users with
[06:35]
WordPress, we this is the only case
[06:37]
where we can see a small difference that
[06:41]
there um is outside of the margin of
[06:43]
error. So we can see for PHP 8.3 4 and 5
[06:48]
the number of requests that we can uh
[06:51]
achieve in a fixed time frame is a
[06:54]
little bit larger than for PHP 7.4. So
[06:57]
um there is this difference between PHP
[07:00]
8 and PHP 7. But again PHP 8.5 is not um
[07:06]
be able to handle more requests per uh
[07:10]
time frame than PHP 8.4 or 8.3.
[07:14]
What do these results mean in general?
[07:16]
Uh so we found out PHP 8.5 is not faster
[07:21]
than PHP 8.4 or previous versions than
[07:24]
PHP. So uh the result that we already
[07:28]
saw last year when we benchmark PHP 8.4
[07:31]
is still true. PHP is at a very high
[07:35]
level of performance for a dynamics
[07:37]
language and achieving general
[07:40]
improvements is really hard at that
[07:42]
point. Uh to achieve changes you
[07:46]
actually need to look at the application
[07:48]
and runtime level of PHP. What you can
[07:52]
obviously do is check the performance of
[07:55]
your PHP application in uh specifically
[07:58]
are there SQL queries that are slow? Are
[08:01]
you using APIs the wrong way? Maybe
[08:03]
there are more modern APIs in PHP now
[08:06]
that you that weren't available
[08:08]
previously.
[08:10]
Uh we published a blog post on
[08:12]
improvements in PHP 8.5 that will
[08:15]
significantly improve the performance of
[08:18]
specific use cases. But uh you need to
[08:21]
find if you are actually using PHP and
[08:24]
using these APIs and are benefiting uh
[08:27]
from them. One thing I want to note here
[08:31]
is for example the persistent storage of
[08:34]
curl state across um requests. Uh this
[08:38]
uh will allow applications that talk to
[08:41]
third party APIs to um improve the
[08:44]
performance quite significantly with
[08:46]
8.5.
[08:48]
You can find a blog post in the
[08:49]
description uh on this um on on the
[08:53]
specific PHP 8.5 performance changes.
[08:57]
A second change that is possible is uh
[09:00]
to rearchitect the way you are using
[09:02]
PHP. You can for example use franken PHP
[09:05]
or any other application server in PHP
[09:08]
to um save time bootstrapping PHP and
[09:12]
reuse state across requests. You can um
[09:16]
move processing out to the background
[09:18]
jobs using message cues and other um
[09:21]
patterns that allow you to reduce the
[09:24]
time spent in the web server. So what is
[09:27]
really possible to make a difference in
[09:30]
application performance is in your
[09:33]
hands. You are um driving this change by
[09:37]
building your application in a way that
[09:39]
ends up being faster for users. If you
[09:41]
like my content on PHP performance, you
[09:44]
can uh continue with this uh video on
[09:47]
PHP 8.5 changes in performance or you
[09:50]
can follow this channel or subscribe to
[09:52]
our newsletter link is in the
[09:54]
description. Bye.