目录
[TOC]
## 压力测试
**设备:**
阿里云服务器
CPU: 2 核 (Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz)
内存:4G
操作系统:Ubuntu 16.04.4 LTS
PHP 版本:7.1.19
**业务:**
简单的在控制器中返回一个字符串。
**工具:**
apaceh ab
**并发:**
10000 连接,100 并发
结果:
```bash
ab -n10000 -c100 -k http://127.0.0.1:8999/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: workerman/3.5.1
Server Hostname: 127.0.0.1
Server Port: 8999
Document Path: /
Document Length: 1 bytes
Concurrency Level: 100
Time taken for tests: 0.281 seconds
Complete requests: 10000
Failed requests: 0
Keep-Alive requests: 10000
Total transferred: 1270000 bytes
HTML transferred: 10000 bytes
Requests per second: 35623.70 [#/sec] (mean)
Time per request: 2.807 [ms] (mean)
Time per request: 0.028 [ms] (mean, across all concurrent requests)
Transfer rate: 4418.17 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 3
Processing: 0 3 1.8 4 8
Waiting: 0 3 1.8 4 8
Total: 0 3 1.8 4 8
Percentage of the requests served within a certain time (ms)
50% 4
66% 4
75% 4
80% 4
90% 4
95% 5
98% 7
99% 8
100% 8 (longest request)
```
## 对比
对比同样环境业务下,传统 web 服务器模型 nginx1.10.3 + php7.1-fpm + laravel5.1 的压测结果:
```bash
ab -n10000 -c100 -k http://127.0.0.1/hello/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: nginx/1.10.3
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /hello/
Document Length: 1 bytes
Concurrency Level: 100
Time taken for tests: 39.039 seconds
Complete requests: 10000
Failed requests: 0
Keep-Alive requests: 0
Total transferred: 9641140 bytes
HTML transferred: 10000 bytes
Requests per second: 256.16 [#/sec] (mean)
Time per request: 390.387 [ms] (mean)
Time per request: 3.904 [ms] (mean, across all concurrent requests)
Transfer rate: 241.18 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 3
Processing: 10 387 126.1 370 1304
Waiting: 10 387 126.1 370 1304
Total: 13 387 126.0 370 1304
Percentage of the requests served within a certain time (ms)
50% 370
66% 412
75% 442
80% 464
90% 535
95% 636
98% 751
99% 797
100% 1304 (longest request)
```