Webbench 工具
一、Webbench介绍
Webbench是有名的网站压力测试工具,它是由 Lionbridge公司(http://www.lionbridge.com)开发。
Webbech能测试处在相同硬件上,不同服务的性能以及不同硬件上同一个服务的运行状况。
webBech的标准测试可以向我们展示服务器的两项内容:每秒钟相应请求数和每秒钟传输数据量。
webbench不但能具有便准静态页面的测试能力,还能对动态页面(ASP,PHP,JAVA,CGI)进 行测试的能力。还有就是他支持对含有SSL的安全网站例如电子商务网站进行静态或动态的性能测试。
webbench最多可以模拟3万个并发连接去测试网站的负载能力。
主页:http://home.tiscali.cz/~cz210552/webbench.html
可从主页中下载webbench。
二、安装
在官网上载源代码包,然后将其解压编译。源码安装方式:
$wget http://下载地址/webbench-1.5.tar.gz$tar zxvf webbench-1.5.tar.gz $cd webbench-1.5 $make && make install
Freebsd 上安装 webbench
Freebsd 上安装 webbench (1) 在FreeBSD下的用Ports安装方法: #cd /usr/ports/benchmarks/webbench#make install clean 记得安装成功以后运行一下rehash命令,刷新一下系统命令 #rehash
ubuntu上安装:
1、安装依赖包CTAGS apt-get install ctags 2、安装 Webbench 下载程序: webbench-1.5.tar.gz wget http://下载地址/webbench-1.5.tar.gz make sudo make install
安装时可能遇到的问题:
问题1: cannot create regular file `/usr/local/man/man1′: No such file or directory 解决方法: 创建/usr/local/man/man1文件来解决 [root@localhost local]# mkdir -m 644 -p /usr/local/man/man1 问题2: /bin/sh: ctags: command not found 解决方法:安装ctags apt-get install ctags 问题3: cc: Command not found 解决方法: 安装gcc apt-get install gcc
参数介绍:
$ 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.
三、使用
1、测试静态页面:
webbench -c 500 -t 30 http://127.0.0.1/php.php
参数说明:-c表示并发数,-t表示时间(秒)
测试结果示例
Webbench – Simple Web Benchmark 1.5 Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.Benchmarking: GET http://127.0.0.1/php.php 500 clients, running 30 sec.
Speed=3230 pages/min, 11614212 bytes/sec. Requests: 1615 susceed, 0 failed.
计算每个请求的响应时间:30/1615 s
Speed=3230 pages/min, 11614212 bytes/sec
每秒钟相应请求数,每秒钟传输数据量
2、查看每分种处理多少pages的测试例子,计划压力测试2小时
方法是使用Web Bench进行并发压力测试,选择的页面是phpinfo.php,并发请求开始5个,每次循环增加5个进入下轮的循环,每一轮循环持续180s,到达最大200个并发时结束。这样就可以持续做2小时的测试。
$ for n in `seq 5 5 50` ; do echo -n $n " " ; webbench -c $n -t 60 http://127.0.0.1/phpinfo.php 2>/dev/null | grep Speed | awk '{print $1}' | awk -F= '{print $2}' ; echo ; done # 可以得到下面数据: clints Pages/Min 5 6824 10 6888 15 6849 20 6867 25 6892 30 6865 35 6846 40 6739 45 6699 50 6880 55 6831 60 6861 65 6847 70 6852 75 6818 80 6813 85 6858 90 6825 95 6840 100 6893 100 6871 105 6858 110 6890 115 6866 120 6893 125 6912 130 6857 135 6892 140 6874 145 6868 150 6891 155 6862 160 6893 165 6877 170 6872 175 6899 180 6855 185 6900 190 6882 195 6890 200 6904
参考资料:

浙公网安备 33010602011771号