phar打包项目压力对比测试
工具 http_load
测试url:
http://api.test.chaoma.me/agent/ad/good_goods/query
http://api.test.chaoma.me/agent/common/area/query
http://api.test.chaoma.me/agent/index/getScreenList
测试url:
http://api.test.chaoma.me/agent/ad/good_goods/query
http://api.test.chaoma.me/agent/common/area/query
http://api.test.chaoma.me/agent/index/getScreenList
测试方法:http_load -rate 100 -seconds 10 简单的一步一步增大rate参数直到fetches无法跟上请求数
左侧为未开启opcache 右侧为开启opcache
N : 无 phar
GPS: phar gz压缩 include phar里的入口文件
GPA: phar gz压缩 include 整个phar包
PS: phar 未gz压缩 include phar里的入口文件
PA: phar 未gz压缩 include整个phar包
未opcahe 未进行phar打包 861 fetches, 48 max parallel, 1.29985e+06 bytes, in 10 seconds 1509.69 mean bytes/connection 86.0999 fetches/sec, 129984 bytes/sec msecs/connect: 0.121065 mean, 0.253 max, 0.059 min msecs/first-response: 268.232 mean, 537.221 max, 20.177 min HTTP response codes: code 200 -- 861
未opcache GZ压缩 phar 引入单独入口文件 857k
550 fetches, 283 max parallel, 834656 bytes, in 10 seconds
1517.56 mean bytes/connection
54.9998 fetches/sec, 83465.4 bytes/sec
msecs/connect: 0.141062 mean, 0.412 max, 0.06 min
msecs/first-response: 1430.25 mean, 4242.23 max, 30.521 min
HTTP response codes:
code 200 -- 550
未opcache GZ压缩 引入全部phar
552 fetches, 282 max parallel, 824349 bytes, in 10 seconds
1493.39 mean bytes/connection
55.1999 fetches/sec, 82434.8 bytes/sec
msecs/connect: 0.141429 mean, 0.293 max, 0.08 min
msecs/first-response: 1399.32 mean, 3991.58 max, 30.834 min
HTTP response codes:
code 200 -- 552
未opcache 未GZ压缩 phar整体引入GZ 2.6M
536 fetches, 297 max parallel, 790063 bytes, in 10.0001 seconds
1474 mean bytes/connection
53.5997 fetches/sec, 79005.8 bytes/sec
msecs/connect: 0.140284 mean, 0.277 max, 0.058 min
msecs/first-response: 1585.57 mean, 3539.12 max, 139.093 min
HTTP response codes:
code 200 -- 536
未opcache 未GZ phar单独引入
530 fetches, 305 max parallel, 800659 bytes, in 10.0001 seconds
1510.68 mean bytes/connection
52.9997 fetches/sec, 80065.4 bytes/sec
msecs/connect: 0.147008 mean, 0.821 max, 0.078 min
msecs/first-response: 1737.13 mean, 5451.6 max, 43.804 min
HTTP response codes:
code 200 -- 530
opcache 未进行phar打包 3331 fetches, 76 max parallel, 4.92848e+06 bytes, in 10 seconds 1479.58 mean bytes/connection 333.1 fetches/sec, 492847 bytes/sec msecs/connect: 0.0978778 mean, 0.354 max, 0.05 min msecs/first-response: 24.289 mean, 297.547 max, 2.476 min HTTP response codes: code 200 -- 3331
opcache GZ压缩 单独引入phar入口文件 2191 fetches, 309 max parallel, 3.25115e+06 bytes, in 10.0001 seconds 1483.86 mean bytes/connection 219.099 fetches/sec, 325113 bytes/sec msecs/connect: 0.14185 mean, 0.46 max, 0.06 min msecs/first-response: 554.939 mean, 3799.93 max, 13.301 min HTTP response codes: code 200 -- 2191
opcahe GZ压缩 整体引入phar包 857k 2027 fetches, 474 max parallel, 2.92806e+06 bytes, in 10.0001 seconds 1444.53 mean bytes/connection 202.698 fetches/sec, 292803 bytes/sec msecs/connect: 0.168372 mean, 0.611 max, 0.063 min msecs/first-response: 678.903 mean, 3901.45 max, 12.343 min HTTP response codes: code 200 -- 2027
opcache 未GZ压缩 单独引入入口文件 大小2.6M 1141 fetches, 526 max parallel, 1.71245e+06 bytes, in 10 seconds 1500.83 mean bytes/connection 114.1 fetches/sec, 171244 bytes/sec msecs/connect: 0.165937 mean, 0.41 max, 0.081 min msecs/first-response: 1210.33 mean, 5786.45 max, 21.29 min HTTP response codes: code 200 -- 1141
opcache 未GZ压缩 整体引入phar 1090 fetches, 576 max parallel, 1.65455e+06 bytes, in 10.0001 seconds 1517.93 mean bytes/connection 108.999 fetches/sec, 165453 bytes/sec msecs/connect: 0.168871 mean, 0.541 max, 0.067 min msecs/first-response: 1253.12 mean, 5429.15 max, 25.819 min HTTP response codes: code 200 -- 1090
每秒处理量降低
without opcache: (8.5-5.5)/8.5 = 35%
opcache: (3300-2200)/3300 = 33%