Although performance improvements of PHP applications are one of the objectives of PeachPie, we always emphasize that it doesn’t necessarily have to be the main one and that we have yet to work on code optimizations to really get the most out of PeachPie. However, recent configuration tweaks have definitely led to surprisingly good results.
Yes, the vision of running PHP apps pre-compiled and JITered on the .NET Core runtime powered by the blazing fast ASP.NET Core framework and Kestrel web server definitely promises great performance improvements. Some 3 years ago, in the times of PHP 5.6, PeachPie would already be crushing the speed contest. PHP, however, is nowhere near the tortoise of old and has undergone some serious performance enhancing treatment since version 7.0 came out in late 2015. So much so that HHVM, the project once conceived by Facebook to speed up its PHP architecture, can no longer keep up with the new and improved PHP.
Theoretically, as PeachPie compiles PHP into MSIL to run natively on the .NET runtime, we should be able to squeeze a bit of extra performance out of PHP apps. Nevertheless, we have been focusing on being as compatible with the regular PHP language as possible in order to be able to run the wide range of PHP applications on PeachPie. We see a lot of potential for major improvements in both compile-time and run-time speed, and we do our best to work these optimizations in whenever we can.
Some time ago, the legendary Ben Adams played around with some quick benchmarks when we first announced WordPress running on .NET Core, and the results back then were already staggering:
— Ben Adams (@ben_a_adams) February 28, 2017
Over 305k req/sec was seriously impressive. We decided that we must become a part of the regularly performed TechEmpower benchmarks and so we added PeachPie to the list. However, there are many configuration options that can potentially skew the results in the wrong direction and so we started off very slowly. With a few configuration tweaks of our own, we were able to improve the results by about 5-10 times, but we were still lagging far behind most other frameworks.
Enter Ben Adams again.
Peachpie running PHP on .NET Core and #aspnetcore's Kestrel is pretty impressive at 452,179 requests per second!
— Ben Adams (@ben_a_adams) June 3, 2018
With some configuration love from Ben, the plaintext benchmark skyrocketed and PeachPie is now significantly faster than any other PHP framework on the list. Coming in on number 10, almost 20 times slower, is HHVM, Facebook’s virtual machine that was, in its earlier form, designed to speed up the once slow PHP the gigantic site runs on.
Below is a larger screenshot of the benchmark, which you can see in its full length here. The results are filtered for PHP frameworks.
We are extremely thankful to Ben Adams for the contribution, and we more than welcome anybody else’s. If you feel like you have something to tweak in the configuration, please do let us know. We are by no means experts in this area.
In other news, we have been implementing missing functions and fixing bugs to be able to run other real world applications. The apps that are known to run on PeachPie so far are WordPress, MediaWiki and a slightly older version of CodeIgniter. Nowadays, we are working on a basic implementation of
cURL, which is needed to run almost all major apps and frameworks, like Laravel and Symfony.