DEV Community

Cover image for PHP Benchmarks (2021) for 20 different PHP platforms  on seven different PHP versions (5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0)

PHP Benchmarks (2021) for 20 different PHP platforms on seven different PHP versions (5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0)

Tomzur πŸš€βœŒοΈ
Originally published at ・2 min read

PHP 8.0 was officially released at the end of 2020. It brings with it many breaking changes. I was tasked with benchmarking it. It was a challenging, month-long endeavor. I hope it's helpful for the community here, and I'm excited to share it with you all.

Quick Summary

PHP 8.0 performs better on most platforms/configurations that do support it. It includes the most popular PHP framework and CMS like Laravel and WordPress. In some cases, PHP 7.4 still performs better. There are a few edge cases, too, where older PHP versions perform better.

You can see a compiled graph image of the top few platforms:
The whole article is too long to be put on here. I've tabulated it below, so it's easy for everyone here. But if you want more details, you can always head to the source.

All the benchmark results are measured in requests per second. The benchmark was done using the Apache Bench tool with 15 concurrent users for 10,000 requests. And just to be sure, each benchmark test was performed 3 times and their average was taken. That's the value you see in the table cells below.

For PHP CMSs, their official images were used with no customizations. For the PHP frameworks, a simple blog-like web app was built to show a huge number of posts pulled from a databaseβ€”more details in the source link.
Test results

The many x (or crosses) in the cells mean that the PHP CMS/framework version tested doesn't support that particular PHP version, or I couldn't set it up to work quickly (mainly due to dependency issues). I may update them in the future if time permits.

One massive caveat: As Laravel founder Taylor Otwell has pointed out before, comparing benchmarks like this to pit one platform against another isn't a good idea. A web app can be optimized in so many ways that even an "unpopular" CMS/framework can be fast with skilled developer hands. Hence, this benchmark only measures how different PHP versions measure up when everything else is maintained a constant.

Another caveat: Though many PHP CMSs and frameworks claim to be PHP 8.0 compatible, and they are, their wider ecosystem (plugins, themes, development tools, etc.) hasn't caught up with it yet. Here's a good piece by the WordPress Core team explaining that.

If you have any questions or suggestions, please go ahead and let me know in the comments.

Source: PHP Benchmarks (2021)

Discussion (0)