21st May 2009

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)
Baseline PHP 2237,05
Cake 1.2.1 101,03
Cake 1.2.3 103,68
CodeIgniter 1.6.2 221,86
CodeIgniter 1.7.1 229,50
Zend 1.7.5 126,90
Zend 1.8.1 128,85

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.

Requests per second

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.

Speed relative to CakePHP

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: 27% [?]

There are currently 19 responses to “PHP Framework benchmark: Zend, CodeIgniter & CakePHP”

Why not let us know what you think by adding your own comment? We're as interesting in your opinion is as the opinions of anyone elses, so come on... make that comment!

  1. 1 On June 10th, 2009, John said:

    Fascinating. Thanks for informing me of this. This is very useful.

  2. 2 On July 12th, 2009, Oliver Nassar said:

    I’ve seen many benchmarks for the frameworks using “Hello World!” examples, but I find them terrible as they don’t imitate real world situations. You should update this blog with a more realistic test? Perhaps the compilation of requests to a blog index page that has 15+ posts, with comment counters, view counters, and more?

    That would be a much more accurate test that I’d love to see.

  3. 3 On July 12th, 2009, Deivinson Tejeda said:

    Hello your article very good, I’m a developer and we would like KumbiaPHP Framework in an upcoming benchmark to evaluate KumbiaPHP, you can see compared to our benchmark framework where these get really good results …

    Congratulations…

  4. 4 On July 23rd, 2009, Mahmoud M. Abdel-Fattah said:

    Finally a benchmark with latest versions !!

  5. 5 On November 25th, 2009, CORNISH HOLIDAY COTTAGE said:

    Your tools seems worthy for a better job. You have done nice work in this post.

  6. 6 On November 25th, 2009, catered chalet ski holidays said:

    Hi, first time here at this blog. Its very worthy to read this post. this tool sounds very good. I thinks that it can improve our work performance.

  7. 7 On December 7th, 2009, bedding sheets said:

    I would like to know more about how to build a web framework, what are the pre requistes to build a web framework. we want to have our own extensions and scripting that has to be handeled by the framework. We would like to develope a layer on appache or Ruby. thanks…

  8. 8 On December 7th, 2009, used autos for sale said:

    I am so pleased to see this great performance test between frameworks..
    when i begun with developing by frameworks i used first Cakephp, but i feel its slowing in processing and rendering data. then i moved to CodeIgniter which i’m using right now to develop php projects. Ruby On Rails…oh God!!.. the best ever the fastest also!!!
    Finally, I’m using CodeIgniter and ROR for my projects:)

  9. 9 On December 24th, 2009, Real Estate Investment in India said:

    I would really love to see is a database based benchmark. The rationale is that the database component is just as key to a framework. The goal is to try to find out how much time requests get “stuck” in the framework especially if you’re using ORM.

  10. 10 On December 30th, 2009, consultant seo said:

    Yii is so much faster because it is using the lazy loading technique extensively. For example, it does not include a class file until the class is used for the first time; and it does not create an object until the object is accessed for the first time. Other frameworks suffer from the performance hit because they would enable a functionality (e.g. DB connection, user session) no matter it is used or not during a request

  11. 11 On February 3rd, 2010, Oscar Ossa said:

    Come on, you begin the spech very well, and finish with a “hello, world” benchmark!!!!!!

    And WHO need FRAMEWORK to make a “hello, world”, you need make more functional functions to benchmark…

    It’s obviously codeigniter it’s best, it’s a mashup of class put together.

    Why you not make a benchmark with PEAR!!!

    You need compare MVC with MVC, CAKE with SYMPHONY or RAILS.

    And again, you REALLY need make this BENCHARK to conclude this great frase:

    “The only conclusion that can really be made after these testresults is that the fancier the framework is, the more performance it’ll cost”.

    I really belive, programers in this thays don’t look to right place:
    IF YOU NEED POWER, go to the source, C, c++ -> php, java.
    IF YOU NEED RAPID DEVELOPMENT, you need know this have a cost associate, J2EE it’s very good, but you need be IBM associate to have machine to do this.

    Time programming versus TIME MACHINE it’s old problem:
    Asembler -> C
    C -> C++
    C++ -> Visual Basic

    sorry, I’m not than older, but I remember days with my ATARI or my COMMODORE, BASIC with 64K of ram, now only navigate you need 2GB RAM, time´s change… LANGUAGES too.

  12. 12 On February 14th, 2010, kakooljay said:

    But what’s the overhead % for a complex app? If you’re choosing a rental car & Hertz has a nicer car but Budget is next door, you might still go the extra distance if you’re renting a car for a long period…

  13. 13 On February 17th, 2010, gun brokers said:

    Hi,what is multimedia what about its fremework how it works?

  14. 14 On July 12th, 2010, pick up lines said:

    Even though its slower I still like cake, however with Google giving more credence to speed of site I may change in the future.

  15. 15 On July 12th, 2010, puppy said:

    I love cake as well, its a bit like clothes, the best looking are not always the most practical. I like design.

  16. 16 On July 22nd, 2010, Search Marketing Group said:

    Your blog provides us a very great information. Its really very helpful to me to find result on search engine. Hope to hear more good information related to searching from your side.

  17. 17 On July 22nd, 2010, Search Marketing Group said:

    I really appreciate the kind of topics you post here. Thanks for sharing us a great information that is actually helpful. Good day

  18. 18 On July 22nd, 2010, Search Marketing Group said:

    I really appreciate the kind of topics you post here. Thanks for sharing us a great information that is actually helpful. Good day
    ———————
    Search Marketing Group

  19. 19 On August 31st, 2010, Letting Agents Cardiff said:

    It’s good to see sites with quality information and thanks for the share that you’ve gave. Usually, I’m quite surprised, but this information really has grabbed my attention.

Leave a Reply

Or you can quickly login using your OpenID URL below.