/php-framework-benchmark

PHP Framework Benchmark

Primary LanguageHTML

PHP Framework Benchmark

This project attempts to measure minimum overhead (minimum bootstrap cost) of PHP frameworks in real world.

So I think the minimum applications to benchmark should not include:

  • cost of template engine (HTML output)
  • cost of database manipulation
  • cost of debugging information

Components like Template engine or ORM/Database library are out of scope in this project.

Benchmarking Policy

This is master branch.

  • Install a framework according to the official documentation.
  • Use the default configuration.
    • Don't remove any components/configurations even if they are not used.
    • With minimum changes to run this benchmark.
  • Set environment production/Turn off debug mode.
  • Run optimization which you normally do in your production environment, like composer's --optimize-autoloader.
  • Use controller or action class if a framework has the functionality.

Some people may think using default configuration is not fair. But I think a framework's default configuration is an assertion of what it is. Default configuration is a good starting point to know a framework. And I can't optimize all the frameworks. Some frameworks are optimized, some are not, it is not fair. So I don't remove any components/configurations.

But if you are interested in benchmarking with optimization (removing components/configurations which are not used), See optimize branch.

If you find something wrong with my code, please feel free to send Pull Requests. But please note optimizing only for "Hello World" is not acceptable. Building fastest "Hello World" application is not the goal in this project.

Frameworks to Benchmark

  1. Phalcon 2.0.8
  2. Ice 1.0.34
  3. Tipsy 0.10.3
  4. FatFree 3.5.0
  5. Slim 2.6.2
  6. CodeIgniter 3.0.2
  7. NoFussFramework 1.2.3
  8. Slim 3.0.0-RC2
  9. BEAR.Sunday 1.0.1
  10. Lumen 5.1.6
  11. zend-expressive 1.0.0rc2 (FastRoute + zend-servicemanager)
  12. Radar 1.0.0-dev
  13. Yii 2.0.6
  14. Silex 1.3.4
  15. Cygnite 1.3.1
  16. FuelPHP 1.8-dev
  17. PHPixie 3.2
  18. Aura 2.0.2
  19. CakePHP 3.1.4
  20. Symfony 2.7.7
  21. Laravel 5.1.24
  22. Zend Framework 2.5.2
  23. TYPO3 Flow 3.0.0

Results

Benchmarking Environment

  • CentOS 6.6 64bit (VM; VirtualBox)
    • PHP 5.5.30 (Remi RPM)
      • Zend OPcache v7.0.4-dev
    • Apache 2.2

Hello World Benchmark

These are my benchmarks, not yours. I encourage you to run on your (production equivalent) environments.

(2015/11/29)

Benchmark Results Graph

framework requests per second relative peak memory relative
phalcon-2.0 1,746.90 64.7 0.27 1.0
ice-1.0 1,454.79 53.9 0.26 1.0
tipsy-0.10 1,425.66 52.8 0.32 1.2
fatfree-3.5 1,106.20 41.0 0.42 1.6
slim-2.6 880.24 32.6 0.47 1.8
ci-3.0 810.99 30.1 0.43 1.7
nofuss-1.2 672.16 24.9 0.40 1.5
slim-3.0 534.16 19.8 0.61 2.4
bear-1.0 442.63 16.4 0.76 2.9
lumen-5.1 412.36 15.3 0.95 3.7
ze-1.0 391.97 14.5 0.80 3.1
radar-1.0-dev 369.79 13.7 0.70 2.7
yii-2.0 379.77 14.1 1.37 5.3
silex-1.3 383.66 14.2 0.86 3.3
cygnite-1.3 385.16 14.3 0.76 2.9
fuel-1.8-dev 346.33 12.8 0.65 2.5
phpixie-3.2 236.58 8.8 1.31 5.1
aura-2.0 233.80 8.7 0.89 3.5
cake-3.1 207.27 7.7 1.37 5.3
symfony-2.7 101.99 3.8 3.21 12.4
laravel-5.1 91.59 3.4 2.76 10.7
zf-2.5 81.13 3.0 3.02 11.7
typo3f-3.0 26.98 1.0 6.50 25.2

Note(1): All the results are run on php with phalcon.so and ice.so. If you don't load phalcon.so or ice.so, the rps except for Phalcon or Ice probably increase a bit.

How to Benchmark

Install source code as http://localhost/php-framework-benchmark/:

$ git clone https://github.com/kenjis/php-framework-benchmark.git
$ cd php-framework-benchmark
$ sh setup.sh

Run benchmarks:

$ sh benchmark.sh

See http://localhost/php-framework-benchmark/.

If you want to benchmark some frameworks:

$ sh setup.sh fatfree-3.5/ slim-3.0/ lumen-5.1/ silex-1.3/
$ sh benchmark.sh fatfree-3.5/ slim-3.0/ lumen-5.1/ silex-1.3/

Linux Kernel Configuration

I added below in /etc/sysctl.conf

# Added
net.netfilter.nf_conntrack_max = 100000
net.nf_conntrack_max = 100000
net.ipv4.tcp_max_tw_buckets = 180000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 10

and run sudo sysctl -p.

If you want to see current configuration, run sudo sysctl -a.

Apache Virtual Host Configuration

<VirtualHost *:80>
  DocumentRoot /home/vagrant/public
</VirtualHost>

References

Other Benchmarks