Pedal to the metal php5.6 vs php5.5 performance (vs php7.0.1)
PHP 5.6 vs 5.5 vs 7.0.1
PHP recently released first PHP7 non-production alpha 1 and as a step towards it i had evaluated the php5.6 version in production environment, trying to squeeze the last bits and bytes of performance with upgrading to latest stable software php stack
Environment
Both instances are used completely the same, under the same load, deployed via puppet (automated deployment)
- EC2 c3.xlarge (4 vCPU, 7.5GiB) with Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
- EC2 Classic, us-east-1c, default tenancy, non-EBS-optimized, EBS & Paravirtual
- Both instances have same production EC2 fine-tuning applied:
- ulimits
- sysctl short overview
- identical nginx,php,fpm configurations (php.ini, nginx.conf, nginx vhosts, pools …) with CPU being the bottleneck
php5.5 box
1st box (originally EC2 ubuntu-precise-12.04-amd64-server-20131003 ami-a73264ce )
- Magnetic EBS volume
- 12.04.3 LTS Updated to 12.04.5 LTS (with apt-get updates)
php5.6 box
2nd box (generic EC2 ubuntu-precise-12.04-amd64-server-20150615 ami-ef05f684)
- SSD (gp) EBS volume
php7.0.1 box
3rd box (generic EC2 ubuntu/images/ebs/ubuntu-trusty-14.04-amd64-server-20151218 ami-b82176d2)
- SSD (gp) EBS volume
Load
Evaluating two projects, expecting php5.6 vs php5.5 performance improvement on php level (cpu)
- ZF-1 JSON-RPC API
- Custom JSON-RPC API
Both running in production for long time, and had been long time optimized to handle high load (up to 1.5k rpm per 1 vCPU).
Both hosts run in EC2 Load balancer which splits load equally between boxes.
The server load generated is organic, coming from clients that use the api’s (its NOT synthetic benchmarks)
ZF-1 API
Custom API
- The spikes are the opcache invalidation calls
- Left side is the php5.5 and the php5.6 on the right side (10:00 php5.6 deployed)
PHP7 (January 2016)
ZF-1 API
Custom API (7.0.1) Jan 2016
Custom API (7.0.4) Apr 2016
Custom API (specific call that is 2x faster on 7.0.1)
php5.6 pros
- php://input better memory management, $HTTP_RAW_POST_DATA deprecated reduced POST data memory usage by 200-300%.
- always_populate_raw_post_data was already set “-1” in 5.5
- MYSQLI_STORE_RESULT_COPY_DATA can reduce the overall memory usage because PHP variables holding results may be released earlie
- mysqli_get_links_stats information about open and cached MySQL links.
- opcache_is_script_cached
php5.6 cons ?
- __debugInfo() added, (maybe affects performance ?)
- phpdbg an interactive integrated debugger SAPI, no way to opt-out, (maybe affects performance ?)
EOL
- lornajane shows 5.6 faster than 5.5
- franontanaya shows 5.6 faster
- reddit shows 5.6 faster by 1.63%
- zsuraski shows 5.6 faster and here
- my own results show me that
- php5.6 is slower or identical to php5.5 in ZF1 and simple JSON-API (PHP/MYSQL app) projects
- php5.6 performance is not as consistent as php5.5 and min&max response times varies more
- php5.6 is sensitive to opcache invalidations opcache_invalidate calls
- PHP 7.0.1 brings significant improvements (20% to 50% in certain calls) even with same code (w/o php7 features)
Update Jan 2016
https://moar.sshilko.com/2015/06/24/PHP56-bench