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