压力测试工具

我们知道压力测试的 软件确实很多,诸如微软的WAST,惠普的LoadRunner以及等等其他的,但这些软件学习起来还是需要花费些时间,在选择上实在头痛,后来在郭欣的 那本《构建高性能WEB站点》上看到了他介绍的这款Apache自带的压力测试工具ab,十分喜爱,于是今天终于有机会体验下ab对网站的压力测试。

实验之前我的apache已经安装了,操作系统:Ubuntu 10.04 VMware 7.0

1、先查看一下版本信息 ab -V(注意是大写的V)

  1. [email protected]:~$ ab -V
  2. This is ApacheBench, Version 2.3 <$Revision: 655654 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/

2、我们也可以使用小写的v查看下ab命令的一些属性 ab -v

  1. [email protected]:~$ ab -v
  2. ab: option requires an argument -- v
  3. ab: wrong number of arguments
  4. Usage: ab [options] [http[s]://]hostname[:port]/path
  5. Options are:
  6. -n requests     Number of requests to perform
  7. -c concurrency  Number of multiple requests to make
  8. -t timelimit    Seconds to max. wait for responses
  9. -b windowsize   Size of TCP send/receive buffer, in bytes
  10. -p postfile     File containing data to POST. Remember also to set -T
  11. -u putfile      File containing data to PUT. Remember also to set -T
  12. -T content-type Content-type header for POSTing, eg.
  13. ‘application/x-www-form-urlencoded‘
  14. Default is ‘text/plain‘
  15. -v verbosity    How much troubleshooting info to print
  16. -w              Print out results in HTML tables
  17. -i              Use HEAD instead of GET
  18. -x attributes   String to insert as table attributes
  19. -y attributes   String to insert as tr attributes
  20. -z attributes   String to insert as td or th attributes
  21. -C attribute    Add cookie, eg. ‘Apache=1234. (repeatable)
  22. -H attribute    Add Arbitrary header line, eg. ‘Accept-Encoding: gzip‘
  23. Inserted after all normal header lines. (repeatable)
  24. -A attribute    Add Basic WWW Authentication, the attributes
  25. are a colon separated username and password.
  26. -P attribute    Add Basic Proxy Authentication, the attributes
  27. are a colon separated username and password.
  28. -X proxy:port   Proxyserver and port number to use
  29. -V              Print version number and exit
  30. -k              Use HTTP KeepAlive feature
  31. -d              Do not show percentiles served table.
  32. -S              Do not show confidence estimators and warnings.
  33. -g filename     Output collected data to gnuplot format file.
  34. -e filename     Output CSV file with percentages served
  35. -r              Don‘t exit on socket receive errors.
  36. -h              Display usage information (this message)
  37. -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
  38. -f protocol     Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)

3、现在我们就对51CTO的网站进行一次压力测试吧,使用命令ab -n1000 -c10 http://www.51cto.com/index.php,其中 -n1000 表示总请求数 -c10表示并发用户数为10 http://www.51cto.com/index.php 表示请求的URL,下面是测试的结果,其中我们最关心的三个指标,我已经注释出来了。

  1. [email protected]:~$ ab -n1000 -c10 http://www.51cto.com/index.php
  2. This is ApacheBench, Version 2.3 <$Revision: 655654 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking www.51cto.com (be patient)
  6. Completed 100 requests
  7. Completed 200 requests
  8. Completed 300 requests
  9. Completed 400 requests
  10. Completed 500 requests
  11. Completed 600 requests
  12. Completed 700 requests
  13. Completed 800 requests
  14. Completed 900 requests
  15. Completed 1000 requests
  16. Finished 1000 requests
  17. /*WEB服务器用的是nginx*/
  18. Server Software:        nginx
  19. Server Hostname:        www.51cto.com
  20. Server Port:            80
  21. Document Path:          /index.php
  22. Document Length:        154 bytes
  23. Concurrency Level:      10
  24. Time taken for tests:   74.373 seconds
  25. Complete requests:      1000
  26. Failed requests:        0
  27. Write errors:           0
  28. Non-2xx responses:      1000
  29. Total transferred:      330000 bytes
  30. HTML transferred:       154000 bytes
  31. /*大家最关心的指标之一,指的是吞吐率
  32. 相当于 LR 中的 每秒事务数 ,后面括号中的 mean 表示这是一个平均值*/
  33. Requests per second:    13.45 [#/sec] (mean)
  34. /*大家最关心的指标之二,指的是用户平均请求等待时间
  35. 相当于 LR 中的 平均事务响应时间 ,后面括号中的 mean 表示这是一个平均值*/
  36. Time per request:       743.726 [ms] (mean)
  37. /*大家最关心的指标之三,指的是服务器平均请求处理时间
  38. Time per request:       74.373 [ms] (mean, across all concurrent requests)
  39. Transfer rate:          4.33 [Kbytes/sec] received
  40. Connection Times (ms)
  41. min  mean[+/-sd] median   max
  42. Connect:      129  163 245.3    145    3154
  43. Processing:   129  576 1510.8    147   11756
  44. Waiting:      129  567 1502.0    147   11756
  45. Total:        261  739 1543.7    294   11888
  46. Percentage of the requests served within a certain time (ms)
  47. 50%    294
  48. 66%    297
  49. 75%    304
  50. 80%    308
  51. 90%   1290
  52. 95%   3452
  53. 98%   7582
  54. 99%   7962
  55. 100%  11888 (longest request)

4、为了使结果更有对比性,我们将并发用户更改为100个进行压力测试,我这里只将三个指标贴出来。

  1. Requests per second:    190.95 [#/sec] (mean)
  2. Time per request:       523.694 [ms] (mean)
  3. Time per request:       5.237 [ms] (mean, across all concurrent requests)

5、将并发用户改为200个进行测试

  1. Requests per second:    186.00 [#/sec] (mean)
  2. Time per request:       1149.433 [ms] (mean)
  3. Time per request:       5.747 [ms] (mean, across all concurrent requests)

6、500个并发用户时的情况

  1. Requests per second:    180.99 [#/sec] (mean)
  2. Time per request:       2631.662 [ms] (mean)
  3. Time per request:       5.263 [ms] (mean, across all concurrent requests)

我们来分析下测试的结果,先对比下吞吐率,当并发用户的时候吞吐率最高为190 reqs/s,当并发用户数为200,500 吞吐率下降了,随之用户的等待时间更是明显增加了,已经有2s的等待时间了。这说明性能明显下降了。当然分析这个测试结果并不是说明51CTO的网站的并 发用户只能在500左右,因为我是在服务器负荷的情况下就行测试的,这显然不能说明问题。另外我们在生产环境下测试的时候,最好能将测试结果做成报表,这 样可以非常清晰地对比出问题来,好了,我该准备下,给上面提交一份我们公司网站的测试报告了。

时间: 2024-08-26 15:31:44

压力测试工具的相关文章

网站压力测试工具 Webbench

webbench最多可以模拟3万个并发连接去测试网站的负载能力 Webbench是有名的网站压力测试工具,它是由 Lionbridge公司(http://www.lionbridge.com)开发. Webbech 能测试处在相同硬件上,不同服务的性能以及不同硬件上同一个服务的运行状况.webBech的标准测试可以向我们展示服务器的两项内容:每秒钟相应请求数 和每秒钟传输数据量.webbench不但能具有便准静态页面的测试能力,还能对动态页面(ASP,PHP,JAVA,CGI)进行测试的能力.还

压力测试工具tsung用法简介

tsung是用erlang开发的一款简单易用的压力测试工具,可以生成成千上万的用户模拟对服务器进行访问.目前对tsung的理解也仅限于会简单的应用,其内部结构没有深入研究过. 1.安装 tsung是用erlang编写的,所以首先安装erlang的运行环境.然后就是按照tsung的官网下载编译tsung.需要注意的是,生成测试报告需要gnuplot和perl的支持,其中perl需要安装Template扩展.具体安装过程请看相关手册或者google之. 2.配置文件 默认情况下,tsung会加载配置

apache压力测试工具的apache bench和JMeter的安装

Apache压力测试工具的安装 1,apache bench的安装 apache  bench工具集成在http的软件包内,可以直接安装apache就可以. 当有些时候,我们不需要用到所有的软件包,我们只需要安装安装其中的某个组件就可以, 例如apache  bench这个组件. 首先安装ab运行需要的软件包apr-util yum install apr-util 然后安装一个yum的工具包,为了可以单独弄出来ab 新建一个目录  mkdir /test 切换目录  cd /test yumd

Linux下四款Web服务器压力测试工具(http_load、webbench、ab、siege)介绍

一.http_load程序非常小,解压后也不到100Khttp_load以并行复用的方式运行,用以测试web服务器的吞吐量与负载.但是它不同于大多数压力测试工具,它可以以一个单一的进程运行,一般不会把客户机搞死.还可以测试HTTPS类的网站请求. 下载地址:http://soft.vpser.net/test/http_load/http_load-12mar2006.tar.gz 安装#tar zxvf http_load-12mar2006.tar.gz#cd http_load-12mar

Web压力测试工具 webbench

在运维工作中,压力测试是一项很重要的工作.比如在一个网站上线之前,能承受多大访问量.在大访问量情况下性能怎样,这些数据指标好坏将会直接影响用户体验.但是,在压力测试中存在一个共性,那就是压力测试的结果与实际负载结果不会完全相同,就算压力测试工作做的再好,也不能保证100%和线上性能指标相同.面对这些问题,我们只能尽量去想方设法去模拟.所以,压力测试非常有必要,有了这些数据,我们就能对自己做维护的平台做到心中有数 1.简介 webbench是知名的网站压力测试工具,它是由Lionbridge公司(

Web压力测试工具Siege介绍

Siege是我所用过的一款不错的网站压力测试工具,它可以非常容易地定制并发访问人数以及并发时间,安装.使用也非常方便,当然它是在Linux环境下使用的,下面来对它作一个介绍. 官方网址:http://www.joedog.org/ 下载网址:ftp://ftp.joedog.org/pub/,进入到ftp://ftp.joedog.org/pub/siege/下载最新版: siege-2.70.tar.gz . 安装解压:tar zxvf siege-2.70.tar.gz,进入到解压后的目录:

Jmeter:图形界面压力测试工具

Jmeter是一款强大的图形界面压力测试工具,完全用Java写成,关于Jmeter的介绍,网上其实有不少的文章,我原本是不想再重复写类似文章的,但我发现有些很关键性的,在我们测试中一定会用到的一些设置或操作很少见到有文章写清楚的,比如有这样的一个常见问题:如何对一个网站的多个链接进行压力测试?因为通常情况下,我们要测试的不是一个链接,假如我们测试的是某一网站的话,而这些链接我们通常都是写入到一个文本文件中,测试的过程中,会随机读取文件中的链接进行压力测试,我们所熟知的一些压力测试工具,例如Sie

十大抢手的网站压力测试工具

两天,jnj在本站发布了<如何在低速率网络中测试 Web 应用>,那是测试网络不好的情况.而下面是十个免费的可以用来进行Web的负载/压力测试的工具,这样,你就可以知道你的服务器以及你的WEB应用能够顶得住多少的并发量,以及你的网站的性能.我相信,北京奥组委的订票网站的开发团队并不知道有这样的测试工具. Grinder –  Grinder是一个开源的JVM负载测试框架,它通过很多负载注射器来为分布式测试提供了便利. 支持用于执行测试脚本的Jython脚本引擎HTTP测试可通过HTTP代理进行

页面静态化1---概念(Apache内置压力测试工具使用方法)

三个概念 ①静态网址: http://127.0.0.1/regis.html ②动态网址:在请求页面时可以动态的传一些值进去. http://127.0.0.1/regis.php?id=45&title=今天天气不错 ③伪静态网址: 伪静态仅仅是对动态网址的一个重写,伪静态网址不能让动态网址静态化,搜索引擎不会认为伪静态就是HTML文档,其次伪静态可取,但是应把重心放在取出冗余参数.规范URL,竟可能的避免重复也等等. 举例说明:http://v.youku.com/v_show/id_XM

Linux下Web网站压力测试工具Webbench

webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好用,安装使用也特别方便,并且非常小. 一,环境:linux 二,安装方式:编译安装 具体步骤如下: 1,安装编译工具: [[email protected] install]# yum install ctags wget make apr* autoconf automake gcc gcc-c++ 2,下载该软件包 [[email protected] install]# wget