Performance Comparison of PHP 5.6 vs. 7.0 vs HHVM
About me - Jani Tarvainen
- Working on the web professionally from 2000 in various roles in development, support operations, management and consulting
- By day I help people build the web at eZ Systems
- By night I do things at Malloc for fun/profit
- On Twitter: @velmu
PHP performance lately
- PHP 5.6
- Opcode cache built in (since 5.5)
- HHVM 3.x
- Increased performance
- Facebook's own Hacklang for features
- PHP 7.0
- Increased performance and more efficient memory use
- New PHP language features
Frontpage
Top Stories
Projects
REST API Call
Memory usage and Response Times
Load Frontpage with empty runtime and Symfony caches
Memory usage and Response Times
Load Frontpage with empty runtime and Symfony caches
Memory usage and Response Times
Load Top Stories page
Memory usage and Response Times
Load Top Stories page
Memory usage and Response Times
Load Projects page
Memory usage and Response Times
Load Projects page
Memory usage and Response Times
Load Frontpage
Memory usage and Response Times
Load Frontpage
Requests served per second
Frontpage without Symfony Reverse Proxy
Requests served per second
Frontpage with Symfony Reverse Proxy
Requests served per second
API without Symfony Reverse Proxy
Requests served per second
API with Symfony Reverse Proxy
Requests served per second
API with Symfony Reverse Proxy
Conclusions
- From a standing start HHVM can be the slowest (JIT)
- HHVM beats PHP 5.6 in memory usage and throughput
- PHP 7.0 is the fastest and uses a significantly than 5.6 or HHVM less memory
- When you've got a lot of template processing, etc. the difference between HHVM and PHP 7.0 closes down, compared to that of the API calls
Adoption
- Prebuilt HHVM packages for Ubuntu, Debian
- PHP 7.0 available for CentOS/RHEL, Debian
- Containers (Docker, etc.) makes runtime packaging easier
- PHP 7.0 is default in Ubuntu 16.04 LTS, release tomorrow (April 21st)
What should I use?
- PHP 5.6 is super safe
- HHVM can be a boost for non PHP 7-compatible apps and Hacklang features
- PHP 7.x is the future, I suggest targeting it
- Some PHP 7 polyfills available: New in Symfony 2.8: Polyfill Components
...PHP-PM and PHPFastCGI?
- Traditionally PHP boots up from scratch
- PHP-PM and PHPFastCGI Running PHP as long running processes
- High performance, but introduce memory leak worries, etc
- Still work in progress, but stabilising
- Details: PHP-FPM vs. PHP-PM (on PHP 7 and HHVM)
PHP-FPM vs. PHP-PM
Frontpage without Symfony Reverse Proxy
PHP-FPM vs. PHP-PM
API without Symfony Reverse Proxy