webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好用,安装使用也特别方便,并且非常小。
一,环境:linux
二,安装方式:编译安装
具体步骤如下:
1,安装编译工具:
[root@zabbix install]# yum install ctags wget make apr* autoconf automake gcc gcc-c++
2,下载该软件包
[root@zabbix install]# wget http://home.tiscali.cz/cz210552/distfiles/webbench-1.5.tar.gz --2016-07-06 19:01:29-- http://home.tiscali.cz/cz210552/distfiles/webbench-1.5.tar.gzResolving home.tiscali.cz... 82.208.6.172Connecting to home.tiscali.cz|82.208.6.172|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 7675 (7.5K) [application/x-tar]Saving to: “webbench-1.5.tar.gz”100%[=====================================================================================>] 7,675 --.-K/s in 0s 2016-07-06 19:01:36 (233 MB/s) - “webbench-1.5.tar.gz” saved [7675/7675]
3,编译安装
[root@zabbix install]# tar zxvf webbench-1.5.tar.gz webbench-1.5/webbench-1.5/webbench.1webbench-1.5/socket.cwebbench-1.5/webbench.cwebbench-1.5/Makefilewebbench-1.5/debian/webbench-1.5/debian/ruleswebbench-1.5/debian/dirswebbench-1.5/debian/copyrightwebbench-1.5/debian/controlwebbench-1.5/debian/changelogwebbench-1.5/COPYRIGHTwebbench-1.5/ChangeLog[root@zabbix install]# cd webbench-1.5[root@zabbix webbench-1.5]# mkdir /usr/local/man #创建该目录否则会失败[root@zabbix webbench-1.5]# makecc -Wall -ggdb -W -O -c -o webbench.o webbench.cwebbench.c: In function ‘alarm_handler’:webbench.c:77: warning: unused parameter ‘signal’cc -Wall -ggdb -W -O -o webbench webbench.o ctags *.c[root@zabbix webbench-1.5]# make installinstall -s webbench /usr/local/bininstall -m 644 webbench.1 /usr/local/man/man1install -d /usr/local/share/doc/webbenchinstall -m 644 debian/copyright /usr/local/share/doc/webbenchinstall -m 644 debian/changelog /usr/local/share/doc/webbench
4,进行压力测试
[root@zabbix webbench-1.5]# webbench -c 100 -t 30 http://192.168.1.245/zabbix.php?action=dashboard.viewWebbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.Benchmarking: GET http://192.168.1.245/zabbix.php?action=dashboard.view100 clients, running 30 sec.Speed=1676 pages/min, 355898 bytes/sec.Requests: 838 susceed, 0 failed.
说明:-c 100:表示同时产生100个并发连接
-t 30:表示持续30秒
备注:webbench最大可以模拟30000个并发连接
实战:方法是使用Web Bench进行并发压力测试,选择的页面是http://192.168.1.245/zabbix.php?action=dashboard.view并发请求开始5个,每次循环增加5个进入下轮的循环,每一轮循环持续180s,到达最大200个并发时结束。这样就可以持续做2小时的测试。
for n in `seq 5 5 50` ; do echo -n $n " " ; webbench -c $n -t 60 http://192.168.1.245/zabbix.php?action=dashboard.view 1>/dev/null | grep Speed | awk '{print $1}' | awk -F= '{print $2}' ; echo ; done
[root@zabbix webbench-1.5]# for n in `seq 5 5 50` ; do echo -n $n " " ; webbench -c $n -t 60 http://192.168.1.245/zabbix.php?action=dashboard.view 1>/dev/null | grep Speed | awk '{print $1}' | awk -F= '{print $2}' ; echo ; done5 Webbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.10 Webbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.15 Webbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.20 Webbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.25 Webbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
本文出自 “清风明月” 博客,请务必保留此出处http://liqingbiao.blog.51cto.com/3044896/1811622