Skip to content

Latest commit

 

History

History
77 lines (54 loc) · 2.39 KB

1.2-压测数据对比.md

File metadata and controls

77 lines (54 loc) · 2.39 KB

1.2 压测数据对比

目标

  1. 对比在相同硬件条件下,PHP Yii2框架在PHP-5.6及PHP7下echo hello world的QPS,并观察平均响应时间及CPU。
  2. 对比现有某服务在PHP-5.6及PHP7下的QPS

工具

ApacheBench即ab,ab -n xx -c xx -k http://www.domain.com/

硬件

aws c4.xlarge(4核8G)

Hello World

PHP-5.6/Yii2

开启opcache,64个php-fpm进程,输出hello world

n c qps 平均响应时间(ms) CPU
10000 1 662.73 1.509 6%
50000 10 1435.35 6.967 76%
500000 20 1577.16 13.375 83%
500000 50 1626.09 145.953 89%

PHP-7/Yii2

开启opcache,64个php-fpm进程,输出hello world

n c qps 平均响应时间(ms) CPU
10000 1 854.81 1.170 18%
50000 10 2008.32 4.979 62%
500000 20 2186.90 9.145 65%
500000 50 2304.98 21.692 69%
500000 200 2331.93 85.766 69%

某服务

  • 1次Redis Get
  • 1次 MongoDB Query
  • 2个广告接口
  • 2个业务接口

PHP-5.6/Yii2

n c qps 平均响应时间(ms) CPU
100 1 4.16 240.168 9%
5000 5 15.36 325.502 46%
5000 10 18.72 534.141 83%
5000 50 19.03 2627.159 99%

PHP-7/Yii2

n c qps 平均响应时间(ms) CPU
100 1 3.51 284.876 5%
5000 5 17.23 290.129 21%
5000 10 32.36 309.057 40%
5000 20 52.94 377.784 82%
5000 40 55.52 720.433 91%

结论

  1. PHP-5.6升级PHP-7.0,Yii2框架的性能提升43%
  2. PHP-5.6升级PHP-7.0,某服务性能提升170%
  3. 单纯将业务升级PHP-7.0,能够提升很大的性能

links