Forest header image

Symfony Finland
Random things on PHP, Symfony and web development

PHP 7.1 vs 7.2 Benchmarks (with Docker and Symfony Flex)

PHP 7.2 will be launching soon, in fact it has already reached Release Candidate status. I was exploring Symfony Flex with Docker setup and thought I would do a quick round of tests to compare the differences in PHP 7.1 and 7.2 (RC4) regarding performance with a few benchmarks.

Like PHP 7.1 before it PHP 7.2 is not promising any significant performance improvements. But it does come with some improvements like Argon2 password hashing and is a drop-in upgrade for most contemporary PHP projects. With containers becoming the norm, switching versions in hosting is a simple operation.

The benchmarked application is the Symfony Flex port of the hybrid application I did back in January. The project now has the required configuration to run it with Docker, and you can find the full source on GitHub. The Docker setup is based on the Symfony Flex example from Kevin Dunglas, which I found a pleasure to work with.

The benchmarks were ran on a Virtual Private Server (VPS) on UpCloud (try free trial for high performance VPS) with a1 CPU and 1GB of RAM. For PHP the setup using the official PHP-FPM images of PHP 7.2 RC4 and PHP 7.1. The database in use is SQLite, with the API controller having some simple TTL caching to verify the DB we're not benchmarking the database.

Benchmarks were ran three times and the average results are displayed. In addition to the standard PHP 7.2 configuration, I also tested with enabling Dead Code Elimination (DCE) optimisations which will be further developed in PHP 7.3.

Results and conclusions

Using the front page controller with Twig rendering there is some differences with PHP 7.1 and 7.2, which result to some percentage points of difference. DCE, it seems like it further boosts performance - making the difference between PHP 7.1 and 7.2 significant at higher concurrencies. Maybe a result of the OPCache improvements?

PHP 7.1 vs PHP 7.2 Dead Code Elimination Benchmarks for JSON API call

When calling the API backend controller without any Twig rendering tasks, the differences between 7.1, 7.2 and 7.2-DCE are quite significant. It seems like the optimisations come into play at 50 & 100 concurrency where 7.1 stalls, but 7.2 remains constant.

PHP 7.1 vs PHP 7.2 Dead Code Elimination Benchmarks for JSON API call

As always, take any benchmark results should be taken with a grain of salt, but PHP 7.2 does seem to deliver a sizeable boost at least with Symfony Flex (with 3.3 components) when running at high concurrencies. There is no PHP 5.7 vs. 7.0 type leap, but as said this was expected. In the meanwhile the team continues to work on 7.3 with further DCE improvements and the JIT engine that has been in the works for some time now.

It is worth noting that there was a memory leak in PHP 7.2 (RC4) when running benchmarks, so you might want to set PHP-FPM setting pm.max_requests to something else than the default value 0 to avoid swapping in long running environments. Notably this only happened with running the rendered page, but not the API endpoint.

More PHP performance articles on this sit:


Written by Jani Tarvainen on Saturday October 14, 2017
Permalink -

« Drop-dead simple SASS builds in Symfony Flex with Webpack Encore - Running Symfony without a web server on Docker using PHP-PM »