介绍
Webbench是一个在Linux下使用的网站压测工具。它使用fork()模拟多个客户端
同时访问我们设定的URL,测试网站在压力下工作的性能,
最多可以模拟3万个并发连接去测试网站的负载能力。
安装准备
首先我肯定需要在本地安装webbench,步骤如下:
下载:[[email protected] tools]# wget http://www.ha97.com/code/webbench-1.5.tar.gz
解压:[[email protected] tools]# tar xf webbench-1.5.tar.gz
安装:
[[email protected] 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
/bin/sh: ctags: command not found
make: [tags] Error 127 (ignored)
[[email protected] webbench-1.5]# echo $?
0
[[email protected] webbench-1.5]# make install
install -s webbench /usr/local/bin
install -m 644 webbench.1 /usr/local/man/man1
install: cannot create regular file `/usr/local/man/man1′: No such file or directory
make: *** [install] Error 1
出现报错,原因是没找到/usr/local/man/man1目录
现在创建:[[email protected] webbench-1.5]# mkdir -p /usr/local/man/man1
再次安装:[[email protected] webbench-1.5]# make
ctags *.c
/bin/sh: ctags: command not found
make: [tags] Error 127 (ignored)
[[email protected] webbench-1.5]# echo $?
0
[[email protected] 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
[[email protected] webbench-1.5]# echo $?
0
完成。
查看webbench使用帮助:
[[email protected] ~]# 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.
在本地服务器进测试:
[[email protected] ~]# webbench -c 1000 -t 10 http://blog.syk.com/test_info.php
Webbench – Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://blog.syk.com/test_info.php
1000 clients, running 10 sec.
Speed=11964 pages/min, 10327965 bytes/sec.
Requests: 1994 susceed, 0 failed
说明:一般我们只用到-c和-t两个参数,其中-c:表示客户端的访问量,即并发数
-t表示运行测试的时间,如果不指定默认是30秒。
结果分析:
- Pages/min:指的输出页数/分
bytes/sec:是指字节/秒这两个指标能反应网站的访问速度。susceed和failed表示请求的成功数目和失败数目,失败的原因虽然没有日志但是应该能猜出是get请求得不到200的响应。
在测试的过程中,再通过浏览器访问被测试的网址能感觉到明显的卡顿。
上面的测试使用了相同的参数(1000的并发数目,30秒),但是不能根据测试结果比较网站的性能。因为还有其它因素,比如测试的当前网页有没有涉及到数据库的访问等等。
下面是CSDN博客首页测试:
[[email protected] ~]# webbench -c 1000 http://blog.csdn.net/
Webbench – Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://blog.csdn.net/
1000 clients, running 30 sec.
Speed=5224 pages/min, 20356 bytes/sec.
Requests: 2612 susceed, 0 failed.
淘宝网测试结果:
[[email protected] ~]# webbench -c 1000 http://www.taobao.com/
Webbench – Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://www.taobao.com/
1000 clients, running 30 sec.
Speed=4970 pages/min, 35821 bytes/sec.
Requests: 2485 susceed, 0 failed.
原文地址:https://www.cnblogs.com/sykblogs/p/9026465.html