webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好用,安装使用也特别方便,并且非常小。
一,环境:linux
二,安装方式:编译安装
具体步骤如下:
1,安装编译工具:
1
|
[root@zabbix
install
]
# yum install ctags wget make apr* autoconf automake gcc gcc-c++
|
2,下载该软件包
1
2
3
4
5
6
7
8
9
|
[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
.gz
Resolving home.tiscali.cz... 82.208.6.172
Connecting to home.tiscali.cz|82.208.6.172|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 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,编译安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
[root@zabbix
install
]
# tar zxvf webbench-1.5.tar.gz
webbench-1.5/
webbench-1.5
/webbench
.1
webbench-1.5
/socket
.c
webbench-1.5
/webbench
.c
webbench-1.5
/Makefile
webbench-1.5
/debian/
webbench-1.5
/debian/rules
webbench-1.5
/debian/dirs
webbench-1.5
/debian/copyright
webbench-1.5
/debian/control
webbench-1.5
/debian/changelog
webbench-1.5
/COPYRIGHT
webbench-1.5
/ChangeLog
[root@zabbix
install
]
# cd webbench-1.5
[root@zabbix webbench-1.5]
# mkdir /usr/local/man #创建该目录否则会失败
[root@zabbix 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@zabbix 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
|
4,进行压力测试
1
2
3
4
5
6
7
|
[root@zabbix webbench-1.5]
# webbench -c 100 -t 30 http://192.168.1.245/zabbix.php?action=dashboard.view
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http:
//192
.168.1.245
/zabbix
.php?action=dashboard.view
100 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
1
2
3
4
5
6
7
8
9
10
11
|
[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 ; done
5 Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
10 Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
15 Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
20 Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
25 Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
|
本文转自 lqbyz 51CTO博客,原文链接:http://blog.51cto.com/liqingbiao/1811622