Enable PHP 7 and measure performance
Enable PHP 7 with the web server.
[root@ip ~]# systemctl enable php-fpm [root@ip ~]# systemctl restart php-fpm
Load the front page in your browser. After a few refreshes the page load time will increase. In my environment, my page load time was 18ms. This is about the limit that can be measured with the browser.
Perform a benchmark test with ab. In order to prevent inconsistencies, change the requests from 100 to 300 and concurrent requests from 10 to 30.
[root@ip ~]# ab -n 300 -c 30 http://ec2-xxx.xxx.compute.amazonaws.com/
In my environment, requests per second was 148.08. Just by changing to PHP 7, our performance increased two-fold over PHP 5.6. And we now have 12.5x the speed of the default environment.
Tuning contents | Page load time | Requests per second |
Default environment | 176ms | 11.24 |
APC | 70ms (251%) | 29.20 |
OPcache+APCu | 66ms (266%) | 30.51 |
MariaDB settings | 64ms (275%) | 31.82 |
Translation accelerator (cache) | 53ms (332%) | 39.29 |
Translation accelerator (disabled) | 36ms (488%) | 56.78 |
gzip | 35ms (502%) | ─ |
Tuned settings | 34ms (517%) | 58.47 |
event MPM+php-fpm | 33ms (537%) | 60.79 |
AWS users | 31ms (567%) | 71.76 |
PHP 5.6+OPCache+APCu | 32ms (550%) | 61.84 (550.2%) |
PHP 7+OPCache+APCu | 18ms (977.7%) | 148.08 (1250.6%) |
Next time, we will install the PHP-compatible execution environment HHVM (HipHop Virtual Machine) developed by Facebook, and achieve 16.9x more performance than the default environment.
[Previous article] [Next article]