当前位置: > Linux服务器 > 性能测试 >

webbench网站压力测试工具安装与使用方法

时间:2015-02-19 13:30来源:linux.it.net.cn 作者:IT

webbench在linux下的安装教程

一、下载Webbench
使用wget或windows下载好导入linux也行,地址:http://home.tiscali.cz/cz210552/distfiles/webbench-1.5.tar.gz

二、编译安装webbench:
 

 
root@jack-desktop:~/software# tar xvzf webbench-1.5.tar.gz   
root@jack-desktop:~/software/webbench-1.5# make  
cc -Wall -ggdb -W -O   -c -o webbench.o webbench.c  
webbench.c: In function ‘alarm_handler’:  
webbench.c:77: warning: unused parameter ‘signal’  
cc -Wall -ggdb -W -O  -o webbench webbench.o    
ctags *.c  
root@jack-desktop:~/software/webbench-1.5# make install  
install -s webbench /usr/local/bin  
install -m 644 webbench.1 /usr/local/man/man1  
install -d /usr/local/share/doc/webbench  
install -m 644 debian/copyright /usr/local/share/doc/webbench  
install -m 644 debian/changelog /usr/local/share/doc/webbench  
root@jack-desktop:~/software/webbench-1.5#   
root@jack-desktop:~/software/webbench-1.5# web  
webbench  webs   

安装成功

三,查看webbench帮助文档
 

root@jack-desktop:~/software/webbench-1.5# webbench --help  
webbench [option]... URL  
  -f|--force               Don't wait for reply from server.  
  -r|--reload              Send reload request - Pragma: no-cache.  
  -t|--time <sec>          Run benchmark for <sec> seconds. Default 30.  
  -p|--proxy <server:port> Use proxy server for request.  
  -c|--clients <n>         Run <n> HTTP clients at once. Default one.  
  -9|--http09              Use HTTP/0.9 style requests.  
  -1|--http10              Use HTTP/1.0 protocol.  
  -2|--http11              Use HTTP/1.1 protocol.  
  --get                    Use GET request method.  
  --head                   Use HEAD request method.  
  --options                Use OPTIONS request method.  
  --trace                  Use TRACE request method.  
  -?|-h|--help             This information.  
  -V|--version             Display program version.  
root@jack-desktop:~/software/webbench-1.5#  


webbench网站压力测试:
 

 
root@jack-desktop:~/software/webbench-1.5# webbench -c 100 http://localhost:12345/test  
Webbench - Simple Web Benchmark 1.5  
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.  
  
Benchmarking: GET http://localhost:12345/test  
100 clients, running 30 sec.  
  
Speed=495888 pages/min, 586798 bytes/sec.  
Requests: 247944 susceed, 0 failed. 



并发100个,运行30s,访问请求全部成功,速度495888 pages/min, 586798 bytes/sec
 

root@jack-desktop:~/software/webbench-1.5# webbench -c 1000 http://localhost:12345/test  
Webbench - Simple Web Benchmark 1.5  
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.  
  
Benchmarking: GET http://localhost:12345/test  
1000 clients, running 30 sec.  
  
Speed=414996 pages/min, 490915 bytes/sec.  
Requests: 207430 susceed, 68 failed. 

并发1000个,运行30s,访问68个失败,速度也慢下来了,414996 pages/min, 490915 bytes/sec

在并发很大时服务器占用资源很厉害,主要是CPU占用过多,有时达到80%以上!

总结:
1、压力测试工作应该放到产品上线之前,而不是上线以后 
2、测试时尽量跨公网进行,而不是内网
3、测试时并发应当由小逐渐加大,比如并发100时观察一下网站负载是多少、打开是否流程,并发200时又是多少、网站打开缓慢时并发是多少、网站打不开时并发又是多少 
4、应尽量进行单元测试,如B2C网站可以着重测试购物车、推广页面等,因为这些页面占整个网站访问量比重较大

 

(责任编辑:IT)
------分隔线----------------------------