Adsense

Thursday 26 February 2015

Performance benchmark of the best PHP frameworks

     There are many assumptions around performance of different PHP frameworks. I frequently hear strong opinions about superiority X over Y in this context. There are companies writing new PHP frameworks from scratch because available solutions are too slow for them. Let’s see what the number are telling.

       Performing a representative benchmark across different framework is not an easy task. There are multiple ways to use each of them. Every use case will give different reading. Lets take routing as an example. Zend Framework 1 by default doesn’t need a routing file. It’s happy to use “/controller/action” pattern. On the other hand Symfony2 comes with a routing configuration. The file has to be read and parsed. That obviously takes some additional CPU cycles but does it mean Symfony2 routing is slower then Zend Framework 1? The answer is (obviously) no.

      Systemarchitect has benchmarked “quick start” projects. That gives some idea on what is the base line for every framework and makes it possible to reproduce my tests (and argue against them).
Code was hosted on Amazon EC2 medium instance. I installed PHP-APC to avoid disk access and code parsing. I also made sure there is no I/O on Apache2 or application level. I set logs and cache paths to “/dev/shm/”. I tweaked projects to make them return roughly the same amount of data (10KB). All virtual hosts had the same mod_rewrite rules. AllowOveride was set to None.

Framework
Req/Sec
Phalcon
822.96
Slim
399.83
Kohana
217.34
Code Igniter
187.78
Silex
179.01
Laravel
135.9
YII
123.5
Fuel PHP
116.34
Hazaar MVC
103.53
Zend Framework 1
103.02
Cake PHP
54.97
Nette
53.48
Symfony2
39.22
Zend Framework 2
36.1

      Based on Systemarchitect’s benchmark, I’m not surprised, Phalcon is beating everyone on the list, as well as seeing Slim to be the second fastest because it’s a micro framework. The Quick Start project didn’t use any templates or layout which obviously contributed to the reading. Zend Framework 1 is twice faster than Symfony2 and Zend Framework 2 but in my experience the number will quickly go down in a real live setup.

     Frameworks should speed up development, performance is a secondary concern. Zend Framework 2 and Symfony2 could do better but it’s not bad. There are ways to improve those numbers on production servers. Don’t reinvent the wheel, learn and use frameworks. There are various options which balance between performance and features.

No comments:

Post a Comment