Forest header image

Symfony Finland
Random things on PHP, Symfony and web development

Benchmarking PHP 8.0 and 7.4 on Symfony 5.2

The PHP 8.0 is scheduled to be released on November 26 2020, soon to be followed by the latest version of the Symfony framework 5.2. This is a quick round of benchmarks done on the latest release of both projects. It's a pure hello world scenario, and should be taken as such. Only relative performance counts. In the real world YMMV.

The benchmarks were done on PHP 8.0-RC5 and Symfony 5.2-RC2. Both are not final versions, but late release candidates that could be very close to the final releases. The execution environment was Hetzner Helsinki datacenter with a Virtual Server CCX11 (2 dedicated vCPU, 8GB RAM) doing the serving, and another to run the benchmarks. The OS was Ubuntu 20.20 with PHP installed from the packages from Ondřej Surý.

The application was a bare-bones Symfony 5.2 application with the lucky number controller action at the root. The action spits out a snippet of HTML with a random number between 100 and 999. I ran the load test with five concurrencies (1, 10, 25, 50, 100) three times for each configuration and used the average number for the report.

A total of five configurations were tested using a PHP-FPM and Nginx setup:

  • PHP 7.4 without OPCache Preloading
  • PHP 7.4 with OPCache Preloading
  • PHP 8.0 without OPCache Preloading
  • PHP 8.0 with OPCache Preloading
  • PHP 8.0 with OPCache Preloading and JIT enabled

The OPCache config the same used for the post benchmarking OPCache Preloading:


# only when preload was enabled

# only when JIT was enabled

Results and conclusion

The load balancing was ran using hey and I report the numbers for throughput (req/s) and response time (ms). The app does not connect to remote services like databases.

Symfony 5.2 on PHP 7.4 and PHP 8.4 - Throughput

With throughput both PHP 7.4 and 8.0 benefit significantly from enabling OPCache Preloading. On average PHP 7.4 is slightly more performant, but not by a significant margin. For throughput there seems to be no change in concurrency 10 to 100, but PHP 8.0 with JIT is curiously less performant as low concurrency but comes alive and edges past 7.4 with OPCache Preloading from at 25+ concurrency onwards.

Symfony 5.2 on PHP 7.4 and PHP 8.4 - Response time

For response times the story is similar as for throughput. Enabling OPCache Preloading yielding better results than an upgrade from PHP 7.4 to 8.0. For response times (smaller is better) PHP 8.0 is slightly better than 7.4, but not by a meaningful margin. Response time is higher at low currency, but stays consistent from 10 to 100. 8.0 with JIT is similar story: It's worst at low concurrency, but best at high load.

All in all the improvements in baseline performance for an application like Symfony is very similar between PHP 8.0 and 7.4. This is not surprising as it has been known that the JIT in PHP 8.0, that was already around in an early form for PHP 7.0, is more beneficial for calculations and other data processing tasks which are CPU bound.

Regarding performance JIT seems to be a mixed bag here, slowing down at low concurrency and providing a significant improvement to throughput over OPCache Preloading only. More investigation needed, but here the case is not clear as it could hinder performance. JIT seems like something to be considered case by case for PHP.

So for now it is safe to say you're not in a hurry to upgrade from 7.4 to 8.0 for performance reasons. You'll be better off by upgrading from PHP 7.3 to 7.4 and enabling OPCache Preloading. That's not to say that PHP 8.0 is a disappointment by any means. It's packed with new language features and important deprecations. Most importantly is good to see that there have been no performance regressions (like there was with the move from 4.4 to PHP 5.0 way back in 2004). A great start for 8.x.

Comments and Feedback welcome on Discourse: PHP 8.0 and 7.4 benchmarks

Written by Jani Tarvainen on Thursday November 26, 2020
Permalink -

« eZ Platform is now Ibexa DXP: A Digital Experience Platform on Symfony - Symfony UX makes Symfony a Full Stack Framework (again) »