当前位置: 首页 > 工具软件 > Webbench > 使用案例 >

Linux之压测工具webbench安装和使用

施博文
2023-12-01

一、webbench简介

  Webbench是知名的网站压力测试工具,它是由Lionbridge公司开发。Web Bench 是用于对 WWW 或代理服务器进行基准测试的非常简单的工具。使用 fork() 模拟多个客户端,可以使用 HTTP/0.9-HTTP/1.1 请求。这个基准测试不是很现实,但它可以测试您的 HTTPD 是否真的可以一次处理那么多客户端(尝试运行一些 CGI)而无需关闭您的机器。
  Webbench能测试处在相同硬件上,不同服务的性能以及不同硬件上同一个服务的运行状况。webbench的标准测试可以向我们展示服务器的两项内容:每秒钟相应请求数和每秒钟传输数据量。webbench不但能具有便准静态页面的测试能力,还能对动态页面(ASP,PHP,JAVA,CGI)进 行测试的能力。还有就是他支持对含有SSL的安全网站例如电子商务网站进行静态或动态的性能测试。Webbench最多可以模拟3万个并发连接去测试网站的负载能力。

二、安装步骤

1、下载软件包

[root@test1 local]# wget http://soft.vpser.net/test/webbench/webbench-1.5.tar.gz
或者在CSDN下载webbench下载链接

2、解压软件包

[root@test1 local]# 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

3、编译安装

[root@test1 webbench-1.5]# make && make install
cc -Wall -ggdb -W -O -c -o webbench.o webbench.c
webbench.c: In function ‘alarm_handler’:
webbench.c:77:31: warning: unused parameter ‘signal’ [-Wunused-parameter]
static void alarm_handler(int signal)
^
cc -Wall -ggdb -W -O -o webbench webbench.o
ctags *.c
/bin/sh: ctags: command not found
make: [tags] Error 127 (ignored)
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、检查是否安装成功

[root@test1 webbench-1.5]# which webbench
/usr/local/bin/webbench

5、查看webbench命令帮助

[root@test1 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 seconds. Default 30.
-p|–proxy <server:port> Use proxy server for request.
-c|–clients <n> Run 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.

三、使用说明

1、使用语法

webbench [option]… URL

2、参数说明

  • -f|–force 不要等待服务器的回复
  • -r|–reload 发送重新加载请求
  • -t|–time <sec> 运行基准测试时间,默认30秒.
  • -p|–proxy server:port 使用代理服务器进行请求
  • -c|–clients 并发http客户端请求,默认1个
  • -9|–http09 使用HTTP/0.9样式的请求
  • -1|–http10 使用HTTP/1.0协议
  • -2|–http11 使用HTTP/1.1协议
  • –get 使用get请求方法
  • –head 使用head请求方法
  • –options 使用选项请求方法
  • –trace 使用跟踪请求方法
  • -?|-h|–help 显示帮助信息
  • -V|–version 显示版本信息

3、使用示例

  • 每秒500个并发测试60秒

[root@test1 local]# webbench -c 500 -t 60 http://192.168.0.213:8098/dist/#/index?id=7e77ad5dab52b8b29a5de3ed985b1535
Webbench - Simple Web Benchmark 1.5
Copyright © Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.0.213:8098/dist/#/index?id=7e77ad5dab52b8b29a5de3ed985b1535
500 clients, running 60 sec.

Speed=211544 pages/min, 373727 bytes/sec.
Requests: 211544 susceed, 0 failed.

  • 每秒5000个并发测试60秒

[root@test1 local]# webbench -c 5000 -t 60 http://192.168.0.213:8098/dist/#/index?id=7e77ad5dab52b8b29a5de3ed985b1535
Webbench - Simple Web Benchmark 1.5
Copyright © Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.0.213:8098/dist/#/index?id=7e77ad5dab52b8b29a5de3ed985b1535
5000 clients, running 60 sec.

Speed=203363 pages/min, 359218 bytes/sec.
Requests: 203332 susceed, 31 failed.

  • 每秒30000个并发测试60秒

[root@test1 local]# webbench -c 30000 -f -t 60 http://192.168.0.213:8098/dist/#/index?id=7e77ad5dab52b8b29a5de3ed985b1535
Webbench - Simple Web Benchmark 1.5
Copyright © Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.0.213:8098/dist/#/index?id=7e77ad5dab52b8b29a5de3ed985b1535
30000 clients, running 60 sec, early socket close.
problems forking worker no. 29631
fork failed.: Resource temporarily unavailable

4、测试结果分析

  • 500个并发的时候发送211544个请求,0失败个,说明web服务器负载OK;
  • 5000个并发的时候发送203332个请求, 31个失败,说明web服务器已经超负荷了;
  • 30000个并发的时候直接提示测试机fork资源不足。
 类似资料: