[原创]Apache的测试工具ab(ApacheBench)源码分析

本文是原创,如果有写得不对的地方,欢迎指正,共同进步!

先看看ab总的流程图,有个总体印象。

 

第二步:ab简介

采用 apache 版本为:apache-­‐2.2.22 

使用:  
在 ubuntu 系统下:  
./ab   -n  
1000   -c   50   -p   post.txt     http://127.0.0.1:9090/query   发送 1000 个请求,每次发 50 个,post 的内容在 post.txt 里。  
提要:  
ab   [   -A   auth-username:password   ]   [   -b   windowsize   ]   [   -c   concurrency   ]   [   -C   cookie-name=value   ]   [   -d   ]   [   -e   csv-file  ]     [  -f  protocol  ]  [  -g  gnuplot-file  ]  [  -h  ]  [  -H  custom-header  ]  [  -i  ]  [  -k  ]  [  -n  requests  ]  [  -p  POST-file  ]     [  -P  proxy-auth-username:password  ]  [  -q  ]  [  -r  ]  [  -s  ]  [  -S  ]  [  -t  timelimit  ]  [  -T  content-type  ]  [  -u  PUT-file  ]     [  -v   verbosity]  [  -V  ]  [  -w  ]  [  -x  <table>-attributes  ]  [  -X  proxy[:port]  ]  [  -y  <tr>-attributes  ]  [  -z  <td>-attributes  ]  [  -Z   ciphersuite  ]     [http[s]://]hostname[:port]/path
注:红色部分是不可缺少部分。  

还可以修改源码,添加需要的option。比如添加-D参数,输出结果:

比如在终端输入命令:   ./ab  –D  2  -n  1000  -c  100  -p  postdata.txt     10.200.34.41/  

第三步: ab源码分析
 
 
 
posted @ 2013-02-07 11:07  度娘818  阅读(2457)  评论(1编辑  收藏  举报