ab的安装apache
1.源码安装apache服务器
apache安装完毕后ab命令存放在apache安装目录的bin目录下。并发
2.yum安装apache工具
若是apache 是经过yum的RPM包方式安装的话,ab命令默认存放在/usr/bin目录下spa
3.没有安装apache直接安装ab.net
若是不想安装apache可是又想使用ab命令的话,咱们能够直接安装apache的工具包httpd-toolstoken
yum -y install httpd-tools源码
ab的使用requests
-c 表示 并发用户数it
-n表示 总请求数
[root@cobbler bin]# ab -c3 -n30 https://10.207.200.100/main/index/index
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 10.207.200.100 (be patient).....done
Server Software: Apache/2.2.15
Server Hostname: 10.207.200.100
Server Port: 443
SSL/TLS Protocol: TLSv1/SSLv3,ECDHE-RSA-AES256-GCM-SHA384,2048,256
Document Path: /main/index/index
Document Length: 295 bytes
Concurrency Level: 3
Time taken for tests: 0.232 seconds
Complete requests: 30
Failed requests: 0
Write errors: 0
Non-2xx responses: 30
Total transferred: 14250 bytes
HTML transferred: 8850 bytes
Requests per second: 129.59 [#/sec] (mean)
Time per request: 23.150 [ms] (mean)
Time per request: 7.717 [ms] (mean, across all concurrent requests)
Transfer rate: 60.11 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 12 19 7.6 16 42
Processing: 0 2 2.4 1 10
Waiting: 0 1 1.0 1 5
Total: 12 21 8.9 17 52
Percentage of the requests served within a certain time (ms)
50% 17 #50%的请求在17S完成
66% 21 #66%的请求在21S完成
75% 22
80% 27
90% 34
95% 36
98% 52
99% 52
100% 52 (longest request)
(1)Requests per second吞吐率
服务器并发处理能力的量化描述,单位是reqs/s,指的是在某个并发用户数下单位时间内处理的请求数。某个并发用户数下单位时间内能处理的最大请求数,称之为最大吞吐率。
计算公式:Complete requests/Time taken for tests
(2)Time per request用户平均请求等待时间
计算公式:Time token for tests/(Complete requests/Concurrency Level)。
(3)Time per requet(across all concurrent request)服务器平均请求等待时间
计算公式:Time taken for tests/Complete requests,正好是吞吐率的倒数。