PHP Framework benchmark: Zend, CodeIgniter & CakePHP
While coding some PHP for simple up to moderately complicated websites I’ve often wondered whether or not I picked the right tools for the job. As most people know by now, the easiest way nowadays to build a website is to use a prebuild CMS such as Joomla – however if you’re fine with the limited options, this is probably not the article for you.
However, if you need more than the fairly limited pre-build scripts can give you, a PHP framework is the right choice. Sadly I’ve only seen a couple of benchmarks of these frameworks and most of those are at least a year old. To get around this, I decided to benchmark the latest and little bit older versions of the Zend Framework, CodeIgniter and CakePHP.
To benchmark these frameworks I used the code from the Web-framework-benchmarks project, which is hosted at Google Code but sadly only has limited activity – and lacks the latest versions. Basically what this script does is set up a webserver for testing, after that the testruns can begin.
During each testrun the benchmark fires away requests for 5 times 1 minute at the different pages set. The frameworks were set up to load the framework and simply display ‘Hello World’. As a comparison a regular PHP script is also included, which merely contains <? echo ‘Hello World’;?>.
A table of the testresults is printed below, for the benchmarking I’ve used a Xubuntu 9.10 setup ran under VirtualBox on a Core2Duo 2.4Ghz processor. Keep in mind that these results are just indications; every system will return different results.
|Requests per second (5 run avg)|
|Zend 1.7.5 order Topamax on line||126,90|
The most interesting, yet logical, result you can see is that using no framework at all is 10 times faster than the fastest framework. Of course performance isn’t the only thing; you’d use a framework for its functions which would reduce the development time and possibly save you some headaches. Because the simple PHP script is not too much of a comparison, I’ve exluded it from the graphs.
The first graph shows the requests per second that each framework could handle during the testruns. Interesting is that CodeIgniter manages to perform the same task twice as fast as CakePHP and Zend Framework do.
The second graph shows the speed of each framework relative to CakePHP 1.2.1. It’s especially good to see that all of the frameworks have increased in speed with their latest versions, however, CakePHP still stays way behind its two rivals.
The only conclusion that can really be made after these testresults is that the fancier the framework is, the more performance it’ll cost. Whereas Zend and CakePHP offer a lot of candy, so to speak, CodeIgniter is a fairly limited framework that sticks to the very basics of the application, leaving the actual development up to you. Deciding what framework will work best for you is still a difficult choice, however, hopefully these benchmarks at least show the difference on a performance level. Happy devving.
Popularity: 73% [?]