说明:
webbench做为linux下的测试工具,最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好。
实现:
1.安装webbench
# yum install gcc ctags # wget http://dl.gaingreat.com/webbench-1.5.tar.gz # tar zxvf webbench-1.5.tar.gz # cd webbench-1.5 # make && make install
2.使用webbench做压力测试
[root@LNMP1 ~]# webbench -c 1000 -t 30 http://www.test.com/info.php //-c表示并发数(最大30000线程),等价于进程数,你可以ps aux|grep webbench 查看一下,-t表示时间(秒) Webbench - Simple Web Benchmark 1.5 Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software. Benchmarking: GET http://www.test.com/info.php 1000 clients, running 30 sec. Speed=18046 pages/min, 16152307 bytes/sec. Requests: 9023 susceed, 0 failed.
附录:
1.ctags: command not found,没有安装ctags
如果没有安装 ctags make 编译会报错:/bin/sh: ctags: command not found
# yum install ctags
2.cc: Command not found,没有安装gcc
# yum install gcc
3.如果出现cannot create regular file `/usr/local/man/man1′: No such file or directory
这时需要创建/usr/local/man/man1文件来解决:
# mkdir -m 644 -p /usr/local/man/man1
4.make出现cc -Wall -ggdb -W -O -c -o webbench.o webbench.c
webbench.c:77: warning: unused parameter ’signal’
cc -Wall -ggdb -W -O -o webbench webbench.o
ctags *.c 的提示,不用理它,