Server Software: nginx
Server Hostname: test.laravel.com
Server Port: 80
Document Path: /api/test
Document Length: 3 bytes
Concurrency Level: 100
Time taken for tests: 148.306 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 253000 bytes
HTML transferred: 3000 bytes
Requests per second: 6.74 [#/sec] (mean)
Time per request: 14830.553 [ms] (mean)
Time per request: 148.306 [ms] (mean, across all concurrent requests)
Transfer rate: 1.67 [Kbytes/sec] received
Server Software: nginx
Server Hostname: test.laravel.com
Server Port: 80
Document Path: /api/test
Document Length: 4 bytes
Concurrency Level: 100
Time taken for tests: 11.006 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 254000 bytes
HTML transferred: 4000 bytes
Requests per second: 90.86 [#/sec] (mean)
Time per request: 1100.590 [ms] (mean)
Time per request: 11.006 [ms] (mean, across all concurrent requests)
Transfer rate: 22.54 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 4.3 0 16
Processing: 409 1069 152.0 1092 1414
Waiting: 408 1069 152.0 1092 1414
Total: 424 1070 149.6 1092 1414
Percentage of the requests served within a certain time (ms)
50% 1092
66% 1126
75% 1149
80% 1162
90% 1203
95% 1242
98% 1280
99% 1309
100% 1414 (longest request)
此时的达到了 90qps,性能是未开启时的 10 倍以上!。
使用swoole加速包
开源的laravel-swoole加速包
在项目目录下运行composer命令安装;在nginx的配置文件中配置,将请求转发到swoole监听的端口。
用 ab 压测 : ab -n 1000 -c 100 http://test.laravel.com/api/test
Server Software: nginx
Server Hostname: test.laravel.com
Server Port: 80
Document Path: /api/test
Document Length: 4 bytes
Concurrency Level: 100
Time taken for tests: 1.158 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 225000 bytes
HTML transferred: 4000 bytes
Requests per second: 863.46 [#/sec] (mean)
Time per request: 115.813 [ms] (mean)
Time per request: 1.158 [ms] (mean, across all concurrent requests)
Transfer rate: 189.72 [Kbytes/sec] received