Ubuntu: 2核4G
1 单线程
1.1 原生epoll
ab -n 200000 -c 1000 http://192.168.253.138:12345/
Server Software:
Server Hostname: 192.168.253.138
Server Port: 12345
Document Path: /
Document Length: 496 bytes
Concurrency Level: 1000
Time taken for tests: 9.922 seconds
Complete requests: 179461
Failed requests: 0
Total transferred: 100762893 bytes
HTML transferred: 89088048 bytes
Requests per second: 18086.48 [#/sec] (mean)
Time per request: 55.290 [ms] (mean)
Time per request: 0.055 [ms] (mean, across all concurrent requests)
Transfer rate: 9917.10 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 9 33 120.2 19 3064
Processing: 9 21 25.4 20 1674
Waiting: 4 15 25.3 14 1671
Total: 28 54 130.6 39 3287
Percentage of the requests served within a certain time (ms)
50% 39
66% 40
75% 41
80% 41
90% 44
95% 49
98% 55
99% 1049
100% 3287 (longest request)
1.2 协程
ab -n 200000 -c 1000 http://192.168.253.138:12345/
Server Software:
Server Hostname: 192.168.253.138
Server Port: 12345
Document Path: /
Document Length: 496 bytes
Concurrency Level: 1000
Time taken for tests: 9.525 seconds
Complete requests: 200000
Failed requests: 0
Total transferred: 112200000 bytes
HTML transferred: 99200000 bytes
Requests per second: 20997.04 [#/sec] (mean)
Time per request: 47.626 [ms] (mean)
Time per request: 0.048 [ms] (mean, across all concurrent requests)
Transfer rate: 11503.26 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.2 0 22
Processing: 14 47 3.7 47 66
Waiting: 9 47 4.4 47 66
Total: 34 47 1.8 47 66
Percentage of the requests served within a certain time (ms)
50% 47
66% 48
75% 48
80% 48
90% 48
95% 49
98% 49
99% 50
100% 66 (longest request)
1.3 比较
单线程状态下,吞吐量相近。
-c并发连接数 对吞吐量没什么影响。
2 多线程
使用协程,使用两个线程,吞吐量和单线程没区别——》猜测,别的地方存在瓶颈
使用火焰图分析