用Webbench进行网站压力测试

这几天一直在做web service想找个工具测试下并发请求处理能力,开始找到了web-ct,windows客户端的,但是安装后用起来很不好,而且免费版最多能测试并发40个,最长10s

这基本上测试不出来什么,还有就是360软件管家卸载不掉,需要去windows控制面板中卸载!恶心....

  今天突然发现一个新大陆,Webbench,是linux下,用这很方便,开源,不限制并发访问次数和时间....大爱啊!

下载Webbench

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

编译安装

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   

ok,安装成功

看看他的帮助文档

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# 

使用



用法很简单,下面简单的测试使用

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网站可以着重测试购物车、推广页面等,因为这些页面占整个网站访问量比重较大





你可能感兴趣的:(用Webbench进行网站压力测试)