压力测试 webbench

原文

webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好用,安装使用也特别方便,并且非常小。

主要是 -t 参数用着比较爽,下面参考了张宴的文章:

  1、适用系统:Linux

  2、编译安装:

[root@hexuweb102 ~]$wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz
[root@hexuweb102 ~]$tar zxvf webbench-1.5.tar.gz
[root@hexuweb102 ~]$cd webbench-1.5
[root@hexuweb102 ~]$make && make install



  3、使用:

[root@hexuweb102 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@hexuweb102 webbench-1.5]$ webbench -c 500 -t 30 http://127.0.0.1/phpinfo.php
</n></n></server:port></sec></sec>


参数说明:-c表示并发数,-t表示时间(秒)

4、测试结果示例:

[root@hexuweb102 webbench-1.5]$ webbench -c 200 -t 30 http://127.0.0.1/phpinfo.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://dev3.smarter.com.cn/index.php
200 clients, running 30 sec.

Speed=1294 pages/min, 3221114 bytes/sec.
Requests: 647 susceed, 0 failed.

 

举个查看每分种处理多少pages的测试例子,计划压力测试2小时:
方法是使用Web Bench进行并发压力测试,选择的页面是phpinfo.php,并发请求开始5个,每次循环增加5个进入下轮的循环,每一轮循环持续180s,到达最大200个并发时结束。这样就可以持续做2小时的测试。

[root@hexuweb102 webbench-1.5]$ 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


很好用的网络压力测试工具 Linux版 siege的安装 unzip filename.zip cd siege-*.*.* ./configure --prefix=/usr/local/siege --mandir=/usr/local/man --with-ssl=/usr/local/ssl mkdir -p /usr/local/siege/etc mkdir -p /usr/local/siege/var make make install 查看配置文件 /usr/local/siege/bin/siege -C 二、siege的使用 举例说明: 50个用户(每次并发量)重复100次 共产生 50*100 个请求 /usr/local/siege/bin/siege -c 50 -r 100 www.baidu.com 50个用户 重复100次 发送GET参数 /usr/local/siege/bin/siege -c 50 -r 100 http://www.baidu.com/s?wd=siege&rsv_spt=1&issp=1&rsv_bp=0&ie=utf-8&tn=baiduhome_pg&rsv_sug3=4&rsv_sug=2&rsv_sug1=4&rsv_sug4=60 50个用户 重复100次 发送POST参数 (注意引号) /usr/local/siege/bin/siege -c 50 -r 100 "https://www.abc.com/a.php POST name=zhangsan" 50个用户 重复100次 发送POST参数(从文件中读取) /usr/local/siege/bin/siege -c 50 -r 100 "https://www.abc.com/a.php POST < /root/ab_test/post.xml" 另外还有挺多参数 详情请man 或 siege -h siege报表解析,请man查看,暂略(有点累了,不想写了。。。。。)。 Transactions: 10 hits :服务器接收的请求数 Availability: 100.00 % :有效情况的比例 Elapsed time: 1.06 secs : 测试所用的时间 Data transferred: 0.04 MB :每个模拟用户的数据传输量 Response time: 0.03 secs :响应每个模拟用户请求的平均时间 Transaction rate: 9.43 trans/sec :服务器每秒处理事务的平均数 Throughput: 0.04 MB/sec :服务器每秒跟所有模拟用户的数据传输量 Concurrency: 0.25 :每秒的模拟连接 Successful transactions: 10 :处理成功的事务数(code<400) Failed transactions: 0 : 处理失败的事务数(code>400) Longest transaction: 0.04 :最长的事务处理时间 Shortest transaction: 0.02 :最短的事务处理时间
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值