Linux下压力测试命令ab

  ab命令被集成到了httpd服务器中,所以想要使用ab命令需要先安装httpd服务。yum -y install httpd

(1).ab命令的使用方法和常用选项

ab [选项] [http[s]://]hostname[:port]/path

常用选项:

-n requests     在测试会话中所执行的请求总个数,默认一个
-c concurrency  一次产生的请求个数,默认一个

(2).实例

  测试会话总共产生1000个请求,一次生成,压力测试

[root@youxi2 ~]# ab -n 1000 -c 1000 http://192.168.5.102/index.html
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.5.102 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache/2.4.6  //被测试的httpd服务器版本
Server Hostname:        192.168.5.102  //服务器主机名
Server Port:            80  //服务器端口

Document Path:          /index.html  //测试的页面文档
Document Length:        7 bytes  //测试的文档大小

Concurrency Level:      1000  //并发数
Time taken for tests:   0.983 seconds  //整个测试时间
Complete requests:      1000  //完成请求个数
Failed requests:        0  //失败请求个数
Write errors:           0
Total transferred:      265000 bytes  //整个测试过程中总传输字节数
HTML transferred:       7000 bytes  //整个测试过程中HTML传输字节数
Requests per second:    1017.58 [#/sec] (mean)  //每秒处理请求数,mean表示这是一个平均值
Time per request:       982.726 [ms] (mean)  //平均请求时间,mean表示这是一个平均值
Time per request:       0.983 [ms] (mean, across all concurrent requests)  //每个请求实际运行时间的平均值,mean表示这是一个平均值
Transfer rate:          263.34 [Kbytes/sec] received  //传输速率

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   40  50.5      0     127
Processing:     8  178 257.1     45     839
Waiting:        8  178 257.2     45     839
Total:         34  218 294.6     47     934

Percentage of the requests served within a certain time (ms)
  50%     47
  66%    112
  75%    349
  80%    541
  90%    919
  95%    928
  98%    931
  99%    933
 100%    934 (longest request)

  注意:测试上限一般是由打开文件的数量决定的,这个数值可以通过ulimit -a或ulimit -n命令查看,默认大小为1024。解决办法就是ulimit -n [数值],来提高打开文件的数量上限,测试和被测试的都要提升。

转载于:https://www.cnblogs.com/diantong/p/11205897.html

你可能感兴趣的:(Linux下压力测试命令ab)