Discuss New Concept,New Technic,New Tools, Including EAI,BPM,SOA,Tibco,IBM MQ,Tuxedo, Cloud,Hadoop,NoSQL,J2EE,Ruby,Scala,Python, Performance,Scalability,Distributed,HA, Social Network,Machine Learning.

February 24, 2011

Symfony2 is one of the fastest PHP frameworks around. We have tested it against the other major PHP frameworks with a simple “Hello World” application and also with a slightly more elaborate application. Here are the results (see below for the methodology and the code).

Benchmark Results

“Hello World” Application

For the “Hello World” application, Symfony2 is about:

• 20% faster than Solar 1.0.0beta3
• 60% faster than Lithium 0.6
• 75% faster than Yii 1.1.1
• 2 times faster than symfony 1.4.2
• 3.5 times faster than Zend 1.10
• 5.5 times faster than CakePHP 1.2.6
• 69 times faster than Flow3 1.0.0alpha7
framework            |      rel |      avg |        1 |        2 |        3 |        4 |        5
-------------------- | -------- | -------- | -------- | -------- | -------- | -------- | --------
baseline-php         |   1.0000 |  5465.30 |  4602.06 |  5509.34 |  5694.15 |  6232.73 |  5288.23
symfony-2.0.0alpha1  |   0.3312 |  1810.07 |  1693.15 |  1846.41 |  1827.51 |  1856.98 |  1826.30
solar-1.0.0beta3     |   0.2825 |  1544.14 |  1293.81 |  1596.28 |  1601.55 |  1613.20 |  1615.86
lithium-0.6          |   0.2128 |  1163.27 |  1059.44 |  1179.42 |  1180.52 |  1197.73 |  1199.25
yii-1.1.1            |   0.1901 |  1038.77 |  1033.20 |  1037.60 |  1038.47 |  1041.57 |  1043.01
symfony-1.4.2        |   0.1737 |   949.59 |   916.84 |   944.49 |   953.88 |   967.52 |   965.24
zend-1.10            |   0.0906 |   494.90 |   320.74 |   519.74 |   537.15 |   546.11 |   550.76
cakephp-1.2.6        |   0.0513 |   280.43 |   255.91 |   279.50 |   291.80 |   291.13 |   283.83
flow3-1.0.0alpha7    |   0.0048 |    26.29 |    23.87 |    26.97 |    26.67 |    26.93 |    27.02

“Product” Application

For the “Product” application, Symfony2 is about:

• 50% faster than Yii 1.1.1
• 2 times faster than Solar 1.0.0beta3
• 2.5 times faster than symfony 1.4.2
• 3 times faster than Zend 1.10
• 4 times faster than Lithium 0.6
• 6 times faster than CakePHP 1.2.6
• 60 times faster than Flow3 1.0.0alpha7
framework            |      rel |      avg |        1 |        2 |        3 |        4 |        5
-------------------- | -------- | -------- | -------- | -------- | -------- | -------- | --------
symfony-2.0.0alpha1  |   1.0000 |  1226.62 |  1100.67 |  1262.34 |  1266.07 |  1252.85 |  1251.16
yii-1.1.1            |   0.6782 |   831.86 |   746.54 |   833.92 |   856.93 |   862.41 |   859.48
solar-1.0.0beta3     |   0.4897 |   600.71 |   485.00 |   598.20 |   636.25 |   644.27 |   639.85
symfony-1.4.2        |   0.3788 |   464.62 |   395.62 |   475.75 |   485.67 |   483.71 |   482.36
zend-1.10            |   0.3391 |   415.94 |   364.02 |   407.42 |   434.83 |   435.51 |   437.94
lithium-0.6          |   0.2684 |   329.33 |   272.51 |   343.73 |   341.70 |   345.07 |   343.65
cakephp-1.2.6        |   0.1657 |   203.30 |   180.73 |   207.39 |   210.07 |   209.52 |   208.79
flow3-1.0.0alpha7    |   0.0165 |    20.27 |    19.55 |    20.45 |    20.51 |    20.48 |    20.34

Benchmark Methodology

During the last few years, Paul M. Jones did an excellent job describing a good methodology to benchmark “the theoretical limit to responsiveness” of a framework. Instead of reinventing the wheel, we have built upon its methodology and we have borrowed the tools he used to benchmark the various frameworks he was interested in. As he said on his blog:

“The purpose of this is not to say that one framework is better than another, or to engage in one-upmanship. The results do not say whether an application will run faster or slower on a particular framework; bad application code will slow you down dramatically on any framework. Similarly, use of full-page caching will bypass the framework completely, raising the responsiveness to something closer to the web-server’s maximum.”

To make the benchmark reproducible by anyone, we have used an Amazon EC2 machine to conduct the benchmark (ami-80446ff4, c1.xlarge):

• 7 GB of memory
• 20 EC2 Compute Units (8 virtual cores with 2.5 EC2 Compute Units each) – One EC2 Compute Unit (ECU) provides the equivalent CPU capacity of a 1.0-1.2 GHz 2007 Opteron or 2007 Xeon processor
• 1690 GB of local instance storage
• 64-bit platform

The benchmarks were done with PHP 5.3.1 (with the Suhosin patch) and APC 3.1.3p1 (no file stat). You can download the code here: http://github.com/fabpot/framework-benchs.

Caution: We are not the best experts for all the frameworks used in this benchmark, far from it. We might have missed some important speed-enhancing technique for one framework or another. If this is the case, please fork the code on Github, make your optimizations, and request a pull.

The “Hello World” Application

The first application is a simple “Hello World”. But as some frameworks like Symfony2 are quite flexible in the way they are configured, we wanted to exercise the whole cycle of a request (from the routing to the view):

• Use of a template
• Routing is enabled
• No page/template cache
• No database access
• No layout/decorator
• No session
• No output escaping

The “Product” Application

The “Product” application exercise common features shared by all frameworks and used in all websites developed with them. This benchmark tries to give a better idea of the performance of the framework in a “real world” situation:

• Use of a template
• Use of sub-templates (15 calls in a loop)
• 30 links using the routing (16 different routes)
• Routing enabled
• Simple layout/decorator
• No page/template cache
• No database access
• No session
• No output escaping