wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz tar zxvf webbench-1.5.tar.gz cd webbench-1.5 make && make install
如果在编译webbench的时候,出现/bin/sh: ctags: command not found,如下
[[email protected]]# 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 /bin/sh: ctags: command not found make: [tags] Error 127 (ignored)
是没安装ctags组件,
sudo apt-get install exuberant-ctags如果安装了ctags, 仍然报错:
install -s webbench /usr/local/bin install -m 644 webbench.1 /usr/local/man/man1 install: cannot create regular file `/usr/local/man/man1′: No such file or directory make: *** [install] Error 1
解决方法
mkdir -m 644 -p /usr/local/man/man1
安装好使用方法
webbench -c 500 -t 30 http://127.0.0.1:8000/en
参数说明:-c表示并发数,-t表示时间(秒)
测试结果示例:
webbench -c 50 -t 30 http://127.0.0.1:8000/en
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://127.0.0.1:8000/en
50 clients, running 30 sec.
Speed=11464 pages/min, 65468 bytes/sec.
Requests: 5727 susceed, 5 failed.
每秒钟响应请求数:11464/60= X pages/sec,每秒钟传输数据量65468 bytes/sec。
当并发5727时,已经显示有5个连接failed了,说明未负荷了。
查看帮助:
[root@centos 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.
测试:
# webbench -c 200 -t 30 http://hi.baidu.com/begin
--参数说明:-c表示并发数,-t表示时间(秒)
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://support.qq.com/discuss/498_1.shtml
200 clients, running 30 sec.
Speed=527 pages/min, 250141 bytes/sec.
Requests:670 susceed, 0 failed.
1、压力及性能测试工作应该放到产品上线之前,而不是上线以后;
2、测试时并发应当由小逐渐加大,比如并发100时观察一下网站负载是多少、打开页面是否流畅,并发200时又是多少、网站打开缓慢时并发是多少、网站打不开时并发又是多少;
3、更详细的进行某个页面测试,如电商网站可以着重测试购物车、推广页面等,因为这些页面占整个网站访问量比重较大。
备注:webbench 做压力及性能测试时,该软件自身也会消耗CPU和内存资源,为了测试准确,建议将 webbench 安装在其他的服务器上,已达到测试数据更加精确。