Laravel: Should I Choose HHVM or PHP-FPM

     

My conclusion: HHVM beats PHP-FPM by 20% to 45% at both request per second and average response time.

Well, if you also include database operation, the time margin should be around the same (the percentage may differ though), considering both HHVM and PHP-FPM consume about same time for database operation.

I ran the test for Lumen 5.2 and Laravel 5.2 using Apache Bench. The PHP version used is 5.6.13 and NGinx version 1.4.6.

If you are curious of ”even better performance for Laravel”, try ReactPHP+NGinx (refer to http://marcjschmidt.de/blog/2014/02/08/php-high-performance.html) because it eliminates Laravel bootstrap’s code just being ran once at server startup, instead of ran at each request (See also https://github.com/php-pm/php-pm). But there is a fatal drawback: If your code throw uncatched exception, your server dies. Also other drawbacks such as reload server on code change and potential memory leaks.

If you need the test results / source code, just contact me. I don’t feel like putting them on this blog.