http_load官网: http://www.acme.com/software/http_load/
1. 下载和安装
进入工作目录:#cd /usr/local/
wget http://acme.com/software/http_load/http_load-12mar2006.tar.gz
tar zxvf http_load-12mar2006.tar.gz
进入http_load 目录:#cd http_load-12mar2006
编译和安装
make && make install
如果遇到错误,可以执行安装:yum -y install gcc gcc-c++
2. 参数使用
-rate 简写-r :含义是每秒的访问频率
-seconds简写-s :含义是总计的访问时间
-parallel 简写-p:并发访问的线程数
urls是一个url 列表,每个url 单独的一行。可以单个页面。
3. 应用
测试网站每秒所能承受的平均访问量
测试网站是否能承受住预期的访问压力
public static void main(String[] args) throws IOException {
FileOutputStream fos = new FileOutputStream("D:/param.txt");
OutputStreamWriter osw = new OutputStreamWriter(fos);
BufferedWriter bw = new BufferedWriter(osw);
for(int i=0; i<500; i++){
bw.write("http://10.32.22.60/vcsp/appData/news/recommend.do?useType=iPhone&
bw.newLine();
bw.flush();
}
bw.close();
osw.close();
fos.close();
}
}
开始测试啦:
./http_load -parallel 1 -seconds 60 urls.txt
如果在输入命令后报错: ./http_load: unknown protocol -, 说明txt文档中有多余的空行,要将其删除。
Note that when you provide a file with a list of URLs make sure that you don't have empty lines in it. If you do, then the utility won't work, complaining:
./http_load: unknown protocol -
大功告成了。
参考资料
Benchmarking Response Times With http_load
http_load is yet another utility that does Web server load testing. It can simulate a 33.6 modem connection (-throttle) and allows you to provide a file with a list of URLs, which we be fetched randomly. You can specify how many parallel connections to run
using the -parallel N option, or you can specify the number of requests to generate per second with -rate N option. Finally, you can tell the utility when to stop by specifying either the test time length (-seconds N) or the total number of fetches (-fetches
N).
A sample run with the file urls including:
http://www.example.com/foo/
http://www.example.com/bar/We ask to generate three requests per second and run for only two seconds. Here is the generated output:
% ./http_load -rate 3 -seconds 2 urls
http://www.example.com/foo/: check-connect SUCCEEDED, ignoring
http://www.example.com/bar/: check-connect SUCCEEDED, ignoring
http://www.example.com/bar/: check-connect SUCCEEDED, ignoring
http://www.example.com/bar/: check-connect SUCCEEDED, ignoring
http://www.example.com/foo/: check-connect SUCCEEDED, ignoring
5 fetches, 3 max parallel, 96870 bytes, in 2.00258 seconds
19374 mean bytes/connection
2.49678 fetches/sec, 48372.7 bytes/sec
msecs/connect: 1.805 mean, 5.24 max, 0.79 min
msecs/first-response: 291.289 mean, 560.338 max, 34.349 minSo you can see that it has reported 2.5 requests per second. Of course, for the real test you will want to load the server heavily and run the test for a longer time to get more reliable results.
Note that when you provide a file with a list of URLs make sure that you don't have empty lines in it. If you do, then the utility won't work, complaining:
./http_load: unknown protocol -