我用webbench测试性能的过程

来源:互联网 发布:现在最流行的网络语言 编辑:程序博客网 时间:2024/05/17 04:55

介绍

Webbench是一个在Linux下使用的网站压测工具。它使用fork()模拟多个客户端同时访问我们设定的URL,测试网站在压力下工作的性能,最多可以模拟3万个并发连接去测试网站的负载能力。

环境准备

被测试的服务运行在centos 6.5的系统上,是一个微信公众号服务。运行webbench的客户端是我本地电脑上运行的一个虚拟机环境,操作系统也是centos 6.5。

首先我肯定需要在本地安装webbench,步骤如下:

[xxx@localhost ~]$ sudo mkdir /usr/local/man[xxx@localhost ~]$ wget http://www.ha97.com/code/webbench-1.5.tar.gz[xxx@localhost ~]$ tar zxvf webbench-1.5.tar.gz [xxx@localhost ~]$ cd webbench-1.5[xxx@localhost webbench-1.5]$ make[xxx@localhost webbench-1.5]$ sudo make install

安装完毕。

输入webbench -help,看下如何使用,

[xxx@localhost webbench-1.5]$ webbench -helpwebbench [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.

一般我们只用到-c和-t两个参数,类似下面这样:

webbench -c 300 -t 60 http://192.168.88.157/phpinfo.php

-t表示运行测试的时间,如果不指定默认是30秒,-c表示客户端数量,也就是并发数。

开始测试

示例1,是csdn博客的首页。

[xxx@localhost webbench-1.5]$ webbench -c 1000 http://blog.csdn.net/Webbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.Benchmarking: GET http://blog.csdn.net/1000 clients, running 30 sec.Speed=1946 pages/min, 1356544 bytes/sec.Requests: 619 susceed, 354 failed.

示例2,是一个可以下载电影的网站。

[xxx@localhost webbench-1.5]$ webbench -c 1000 http://www.kanxi.cc/Webbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.Benchmarking: GET http://www.kanxi.cc/1000 clients, running 30 sec.Speed=1440 pages/min, 1062907 bytes/sec.Requests: 202 susceed, 518 failed.

示例3,是我公司的一个网站,用于商户管理,查询交易记录等功能。该网站是java写的,用了struts+spring+hibernate的框架。

[xxx@localhost webbench-1.5]$ webbench -c 1000 http://xxx.xxx.xxx.xxx:8080/INNPay/login.jspWebbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.Benchmarking: GET http://xxx.xxx.xxx.xxx:8080/INNPay/login.jsp1000 clients, running 30 sec.Speed=5812 pages/min, 461707 bytes/sec.Requests: 2786 susceed, 120 failed.

示例4,是我公司一个公众号服务地址。php写的,没有用任何的框架。

[xxx@localhost webbench-1.5]$ webbench -c 1000 http://xxx.xxx.xxx/inn_wechat_nofity/mc_login.phpWebbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.Benchmarking: GET http://xxx.xxx.xxx/inn_wechat_nofity/mc_login.php1000 clients, running 30 sec.Speed=13790 pages/min, 449270 bytes/sec.Requests: 6192 susceed, 703 failed.

结果分析

Pages/min:指的输出页数/分
bytes/sec:是指比特/秒

这两个指标能反应网站的访问速度。susceed和failed表示请求的成功数目和失败数目,失败的原因虽然没有日志但是应该能猜出是get请求得不到200的响应。

在测试的过程中,再通过浏览器访问被测试的网址能感觉到明显的卡顿。

上面的测试使用了相同的参数(1000的并发数目,30秒),但是不能根据测试结果比较网站的性能。因为还有其它因素,比如测试的当前网页有没有涉及到数据库的访问等等。

1 0
原创粉丝点击