第一步:安装
apt-get install apache2-utils
如果系统没有更新请先更新系统资源
apt-get update
安装完成后输入以下命令,查看版本
~# ab -V
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://
Licensed to The Apache Software Foundation, http:
第二步:测试
-c 10 并发用户数
-n 100 总请求数
-
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
-
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
-
Licensed to The Apache Software Foundation, http://www.apache.org/
-
-
Benchmarking localhost (be patient).....done
-
-
-
Server Software: Apache-Coyote/1.1
-
Server Hostname: localhost
-
Server Port: 80
-
-
Document Path: /index.jsp
-
Document Length: 203 bytes //响应数据的长度
-
-
Concurrency Level: 10 // 并发用户数,参数
-
Time taken for tests: 0.145 seconds // 所有请求被处理完成所花费的总时间
-
Complete requests: 100 // 总请求数
-
Failed requests: 77 // 失败的请求数
-
(Connect: 0, Receive: 0, Length: 77, Exceptions: 0)
-
Total transferred: 93875 bytes
-
HTML transferred: 77823 bytes
-
Requests per second: 688.21 [#/sec] (mean) //吞吐率
-
Time per request: 14.530 [ms] (mean) // 用户平均请求等待时间
-
Time per request: 1.453 [ms] (mean, across all concurrent requests) // 服务器平均请求处理时间
-
Transfer rate: 630.92 [Kbytes/sec] received
-
-
Connection Times (ms)
-
min mean[+/-sd] median max
-
Connect: 0 0 0.6 0 3
-
Processing: 0 9 21.8 2 138
-
Waiting: 0 8 21.6 1 138
-
Total: 1 9 21.8 2 139
-
-
Percentage of the requests served within a certain time (ms)
-
50% 2
-
66% 3
-
75% 3
-
80% 3
-
90% 55
-
95% 57
-
98% 99
-
99% 139
-
100% 139 (longest request)
第三步:数据统计查找最优
并发用户数
|
请求等待时间(ms)
|
请求处理时间(ms)
|
吞吐率(reqs/s)
|
1
|
0.316
|
0.316
|
3164.12
|
5
|
1.267
|
0.253
|
3946.41
|
10
|
2.693
|
0.269
|
3713.81
|
20
|
6.365
|
0.318
|
3142.07
|
50
|
13.876
|
0.278
|
3603.32
|
100
|
26.831
|
0.268
|
3727.02
|
200
|
52.462
|
0.262
|
3812.27
|
400
|
114.739
|
0.287
|
3486.17
|
600
|
182.193
|
0.304
|
3293.21
|
800
|
227.7
|
0.285
|
3513.39
|
阅读(918) | 评论(0) | 转发(0) |