Search This Blog

Thursday, April 25, 2013

Performance benchmark of popular PHP frameworks | Systems Architect

Performance benchmark of popular PHP frameworks | Systems Architect:


Performance benchmark of popular PHP frameworks

php
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. What does it really mean? Does the framework performance matters? Before answering this questions lets check how slow is your framework!

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. Zend1 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 Zend1? The answer is (obviously) no.
I 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 disc 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.
Benchmarked frameworks:
I’m happy to extend this list if you have any suggestions.
Requests per second from Apache Benchamrk with c=20 and n=500.
FrameworkReq/Sec
Slim399.83
Kohana217.34
Code Igniter187.78
Silex179.01
Laravel135.9
YII123.5
Fuel PHP116.34
Hazaar MVC103.53
Zend 1103.02
Cake PHP54.97
Nette53.48
Symfony239.22
Zend 236.1
PHP Framework performance
I’m not surprised, Slim is the fastest because it’s a micro framework. The Quick Start project didn’t use any templates or layout which obviously contributed to the reading.
Zend1 is twice faster than Symfony2 and Zend2 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 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.
ps. If you have space for more I would like to recommend you great research on performance of web frameworks by techempower.

No comments:

Post a Comment