benchmarking php frameworks

over on the avnet labs blog, ekerete akpan has posted a few results from his recent framework benchmarks to much controversy.

his tests covered a few major php frameworks, such as codeigniter, cakephp and zend framework, along with baseline results for serving static html and procedural php versions of the same page. he also covered some basic ruby on rails, including passenger (mod_rails?) and ruby enterprise. here are some of his more interesting findings.

after running the tests on a production grade box, he recorded these basic results, without any caching in place.

 

run 1
run 2
run 3
run 4
average
baseline html
3431.2
3311.8
3427.7
3395.0
3391.4
baseline php
1912.1
1932.3
1983.3
1911.3
1934.7
cakephp
15.6
15.6
15.6
15.6
15.6
codeigniter
83.5
83.0
82.0
83.2
82.9
zend framework
34.7
34.6
34.6
34.6
34.6

some basic indications are obvious – frameworks create massive overheads, with hefty overall performance costs. per these results, using cakephp over a static html site was 226 times slower. codeigniter fared the best, at about 40 times slower, while the zend framework was somewhere in between.

while the actual numbers may be surprising, how each framework fared in relation to the others is not.

all of these frameworks provide levels of abstraction, taking care of many common tasks and moving the logic away from the developer’s application. each framework offers a varying level of this “hand holding”, and it’s generally accepted that cakephp leads the race in this area. by making more assumptions and relying on more default behaviours, cake will always have a far greater overhead.

codeigniter, on the other hand, is far more efficient in what it does – but doesn’t do as much. an application built on codeigniter will always be more efficient than one built in cake, but development time will be considerably longer.

another interesting area to note was orm – cake’s inbuilt orm layer couldn’t be reasonably “disabled” to run benchmarks without the added overhead, and so the benchmark of frameworks without their orm layer excluded cake entirely. ekerete also notes that codeigniter doesn’t have much of an orm implementation, possibly leading to its vastly increased performance over the other frameworks.

however, the final point to consider was caching. the performance (measured in requests per second) of codeigniter and zend framework increased by about 4x when the eaccelerator cache was used. on the other hand, cake’s requests per second figure barely doubled, suggesting that cake’s architecture imposes some limitations on the performance gains achievable through caching. with eaccelerator, codeigniter was serving over ten times as many requests per second than cake.

in the end, the choice is really up to the developer. if your applications tend to grow in complexity very quickly, your choice of framework (or language, for that matter) will be increasingly irrelevant. on the other hand, if you’re building small applications, cakephp will clearly save you time in development, codeigniter will offer massive performance benefits, and zend will give you a reasonable middle ground.

check out the post on avnet labs for more details.