码迷,mamicode.com
首页 > Web开发 > 详细

apache ab概述

时间:2017-04-30 16:12:07      阅读:479      评论:0      收藏:0      [点我收藏+]

标签:admin   4.0   测试   exe   调用   响应   log   测试的   lib   

一、apache ab 简介

apache ab是apache下的小的性能测试工具

 

二、apache ab 路径

linux下apache的安装方式:

1、yum安装的apache ab 路径:cd /usr/sbin/

2、rpm安装的apache ab 路径:cd /opt/lampp/bin

 

三、apache ab查看和使用简介

1、apache ab查看:

[root@besttest ~]# cd /opt/lampp/
[root@besttest lampp]# ls
apache2 ctlscript.sh htdocs info licenses manual php RELEASENOTES uninstall
bin docs icons lampp logs modules phpmyadmin sbin uninstall.dat
build error img lib man mysql proftpd share var
cgi-bin etc include libexec manager-linux.run pear properties.ini temp xampp
[root@besttest lampp]# cd bin
[root@besttest bin]# ll ab
-rwxr-xr-x. 1 root root 48408 2月 13 2014 ab
[root@besttest bin]# ./ab  → 查看帮助
./ab: wrong number of arguments
Usage: ./ab [options] [http[s]://]hostname[:port]/path → 标识使用方式
Options are:
-n requests Number of requests to perform → 执行的请求数
-c concurrency Number of multiple requests to make at a time → 一次发出请求的数量

。。。 。。。

。。。 。。。

 

2、apache ab使用:

[root@besttest bin]# ./ab -n 1000 -c 10 http://sports.163.com/
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 sports.163.com (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: openresty
Server Hostname: sports.163.com
Server Port: 80

Document Path: /
Document Length: 415744 bytes

Concurrency Level: 10  → 10个并发
Time taken for tests: 70.788 seconds → 10个并发发送1000次请求耗时(70.788 seconds*10/10并发=Time per request: 707.875 [ms] (mean) → 平均每次请求的响应时间)
Complete requests: 1000 → 请求的次数
Failed requests: 0 → 失败的请求数

Non-2xx response: 0 → 非2开头的请求数,2xx http请求状态码
Total transferred: 416130766 bytes
HTML transferred: 415744000 bytes
Requests per second: 14.13 [#/sec] (mean)
Time per request: 707.875 [ms] (mean) → 平均每次请求的响应时间
Time per request: 70.788 [ms] (mean, across all concurrent requests) → 服务器的平均响应时间,不包含发送请求的时间(tps)
Transfer rate: 5740.81 [Kbytes/sec] received

Connection Times (ms)
                       min   mean(平均耗时)[+/-sd](标准方差)   median(中间值)   max(最大耗时)
Connect:          21       59                   21.2                     59                 352    → 连接服务器耗时(线程池排队)
Processing:      475     646                  93.6                     635               1744  → 请求处理耗时
Waiting:          27       86                   69.7                     76                 713    →等待处理耗时 
Total:             527     706                  94.0                     689               1805   →平均每次请求的响应时间

Percentage of the requests served within a certain time (ms)
50%     689 →50%的用户响应时间小于689ms
66%    714
75%    728
80%    742
90%    785
95%    855
98%    949
99%   1142
100% 1805 (longest request)

 

四、apache ab和loadrunner的性能测试结果比较

测试人员使用lr对某系统的某功能测试得出tps=100,开发用apache ab测相同系统的相同功能得出tps=3000,为什么使用两个测试工具相差那么大?

别人测试结果和自己的测试结果不一样,关注如下:

1、测试环境(测试环境/开发环境);

2、数据量;

3、测试的是否是同一个系统功能;

4、测试工具不一样。

apache ab只发送请求不接收服务器返回结果,发送到服务器的状态值为200,就认为请求成功结束了

loadrunner发请求后,会接收服务器返回结果(同理服务器返回成功会有个2xx的状态码),这个请求才算结束

使用apache ab进行性能测试时候,对tps很大程度取决于CPU的核数,性能好的服务器通过apache ab进行性能测试,有的时候得出的测试结果会相差较大

linux top命令,可以查看系统cpu的核数

所以apache ab会比lr快很多

 

五、什么时候使用apache ab

1、开发测试性能会用apache ab

2、看看服务器是否支持10W个tps。

Controller应与Load Generator分开,若测试需要的vu数,超过单负载机所能产生的vu数,则负载机本身将成为性能瓶颈,这是不合理的。例如,负载机内存512M,一个vu占2.5M,则单台负载机只能产生200vu,若需测试500vu,一台controller调用多台Generator,要考虑负载均衡问题,带宽问题。

 

六、如何判断apache ab请求是否成功

1、lr可以用检查点判断请求是否成功

2、如何判断apache ab请求是否成功:

①通过这个"Usage: ./ab [options] [http[s]://]hostname[:port]/path → 标识使用方式"命令,打印出来的响应信息中,没有Non-2xx response: 0;

②检查服务器打印的日志状态是否为2xx/3xx状态码。

 技术分享

 

apache ab概述

标签:admin   4.0   测试   exe   调用   响应   log   测试的   lib   

原文地址:http://www.cnblogs.com/lz2lhy/p/6788281.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!