Apache AB性能测试工具使用教程

这篇文章主要介绍了Apache AB性能测试工具使用教程,本文重点讲解测试结果中的一些参数,对参数的含义一一解释,需要的朋友可以参考下

服务器负载太大而影响程序效率是很常见的,Apache服务器自带有一个叫ab(ApacheBench)的工具,在bin目录下。ab专门用于HTTP Server的benchmark testing,可以同时模拟多个并发请求,使用这个轻巧的工具我们可以对服务器进行负载测试。

今天在公司也用它作一些测试,现在整理了下它的一些东西分享下。

首先我们要得到Apache服务器的目录下bin的路径,我电脑中的路径是D:\wamp\bin\apache\Apache2.2.21\bin,打开cmd,转到这个目录下,在其中输入:ab -n 10 -c 10 http://www.jb51.net/ 这条指令,这条指令的意思是:ab -n 全部请求数 -c 并发数 测试URL。这里值得注意的是,如果你的测试URL是一个网站的网址,请记得在其后加上/,否则会无法工作。

以下是我运行的结果:


D:\wamp\bin\apache\Apache2.2.21\bin>ab -n 10 -c 10 http://www.jb51.net/

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.jb51.net (be patient)…..done

Server Software:        Microsoft-IIS/6.0  //Microsoft-IIS服务器版本6.0

Server Hostname:        www.jb51.net  //服务器主机名

Server Port:            80  //服务器端口
Document Path:          /  //测试的页面文档

Document Length:        32639 bytes  //文档大小
Concurrency Level:      10  //并发数

Time taken for tests:   13.548 seconds  //整个测试持续的时间

Complete requests:      10  //完成的请求数量

Failed requests:        0  //失败的请求数量

Write errors:           0

Total transferred:      331070 bytes  //整个场景中的网络传输量

HTML transferred:       326390 bytes  //整个场景中的HTML内容传输量

Requests per second:    0.74 [#/sec] (mean)  //每秒事务数 ,后面括号中的 mean 表示这是一个平均值

Time per request:       13547.775 [ms] (mean)  //平均事务响应时间 ,后面括号中的 mean 表示这是一个平均值

Time per request:       1354.777 [ms] (mean, across all concurrent requests)  //每个请求实际运行时间的平均值

Transfer rate:          23.86 [Kbytes/sec] received  //平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题
Connection Times (ms)  //网络上消耗的时间的分解

              min  mean[+/-sd] median   max

Connect:        1    2   0.8      2       3

Processing:  2163 3981 3420.2   2957   13540

Waiting:     1305 3204 3595.3   2096   13169

Total:       2164 3983 3420.0   2959   13541

//以下是整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中50%的用户响应时间小于2959毫秒,66% 的用户响应时间小于3074毫秒,最大的响应时间小于13541 毫秒。由于对于并发请求,cpu实际上并不是同时处理的,而是按照每个请求获得的时间片逐个轮转处理的,所以基本上第一个Time per request时间约等于第二个Time per request时间乘以并发请求数。

Percentage of the requests served within a certain time (ms)

  50%   2959

  66%   3074

  75%   3974

  80%   4008

  90%  13541

  95%  13541

  98%  13541

  99%  13541

 100%  13541 (longest request)

下面是ab的指令中参数的介绍:

-n requests     全部请求数

-c concurrency  并发数

-t timelimit    最传等待回应时间

-p postfile     POST数据文件

-T content-type POST Content-type

-v verbosity    How much troubleshooting info to print

-w              Print out results in HTML tables

-i              Use HEAD instead of GET

-x attributes   String to insert as table attributes

-y attributes   String to insert as tr attributes

-z attributes   String to insert as td or th attributes

-C attribute    加入cookie, eg. ‘Apache=1234. (repeatable)

-H attribute    加入http头, eg. ‘Accept-Encoding: gzip'

                Inserted after all normal header lines. (repeatable)

-A attribute    http验证,分隔传递用户名及密码

-P attribute    Add Basic Proxy Authentication, the attributes

                are a colon separated username and password.

-X proxy:port   代理服务器

-V              查看ab版本

-k              Use HTTP KeepAlive feature

-d              Do not show percentiles served table.

-S              Do not show confidence estimators and warnings.

-g filename     Output collected data to gnuplot format file.

-e filename     Output CSV file with percentages served

-h              Display usage information (this message)

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

安装 Apache 出现 OS 10013 以一种访问权限不允许的方式做了一个访问套接字的尝试 如下截图: 提示: make_sock: could not bind to address 0.0.0.0:80 这个问题有由于计算机上安装了IIS7,80端口已占用。 打开Apache 的配置文件 Apache安装目录下的conf/htt
apache web服务器的站点,下载pptx,docx,xlsx文件,却被浏览器当作zip文件保存。 这不是浏览器的问题,而是apache不认docx,pptx,,xlsx等Microsoft Office 2007+的文件格式,而这些文件本身是zip压缩文件,所以被apache当作zip压缩文件发给浏览器了。 做个形
网站目录文件权限的设置对网站的安全至关重要,下面简单介绍网站目录文件权限的基本设定。 我们假设http服务器运行的用户和用户组是www,网站用户为centos,网站根目录是/home/centos/web。 我们首先设定网站目录和文件的所有者和所有组为centos,www,如下
Apache mod_ssl 配置多个虚拟主机支持SSL子站,以下配置适用于httpd 2.4+,对于不支持define指令的低版本Apache httpd Web Server,把SSLROOT换成所定义的路径即可。配置中的${WROOT}是httpd.conf中通过define指令定义的一个变量,值为D:/Web/www/ 在httpd.c
在apache的配置文件http.conf中最下面加入了这句,把这段注销掉或者去掉再重启apache就可以启动了! #Begin SafeDogSite-ApacheFilter edits - remove only on uninstall Include d:/wamp/bin/apache/apache2.4.4/conf/SafeDogSiteApacheFilter.Conf #End Sa
在windows和RH都碰到过,只要把主目录指到其他地方后就出现权限不够的403提示,郁闷了好久。