apacheBench对网站进行压力测试

news/2024/4/27 18:36:23/文章来源:https://blog.csdn.net/dcj3sjt126com/article/details/84709000

   ab 的全称是 ApacheBench , 是 Apache 附带的一个小工具 , 专门用于 HTTP Server 的 benchmark testing , 可以同时模拟多个并发请求。前段时间看到公司的开发人员也在用它作一些测试,看起来也不错,很简单,也很容易使用,所以今天花一点时间看了一下。

通过下面的一个简单的例子和注释,相信大家可以更容易理解这个工具的使用。

一个简单的例子

/* 在这个例子的一开始,我执行了这样一个命令 ab -n 10 -c 10 http://www.google.com/  这个命令的意思是启动 ab ,向 www.google.com 发送10个请求(-n 10)   ,并每次发送10个请求 (-c 10)——也就是说一次都发过去了 。跟着下面的是 ab 输出的测试报告,红色部分是我添加的注释。 */

C:\Program Files\Apache Software Foundation\Apache2.2\bin>ab -n 10 -c 10 http

://www.google.com/

This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0

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

Copyright 1997-2005 The Apache Software Foundation, http://www.apache.org/

 

Benchmarking www.google.com (be patient).....done

 

 

Server Software:        GWS/2.1

Server Hostname:        www.google.com

Server Port:            80

 

Document Path:          /

Document Length:        230 bytes

 

Concurrency Level:      10

/* 整个测试持续的时间 * /

Time taken for tests:   3.234651 seconds

/* 完成的请求数量 */

Complete requests:      10

/* 失败的请求数量 */

Failed requests:        0

Write errors:           0

Non-2xx responses:      10

Keep-Alive requests:    10

/* 整个场景中的网络传输量 */

Total transferred:      6020 bytes

/* 整个场景中的 HTML 内容传输量 */

HTML transferred:       2300 bytes

/* 大家最关心的指标之一,相当于 LR 中的 每秒事务数 ,后面括号中的 mean 表示这是一个平均值 */

Requests per second:    3.09 [#/sec] (mean)

/* 大家最关心的指标之二,相当于 LR 中的 平均事务响应时间 ,后面括号中的 mean 表示这是一个平均值 */

Time per request:       3234.651 [ms] (mean)

/* 这个还不知道是什么意思,有知道的朋友请留言,谢谢 ^_^ */

Time per request:       323.465 [ms] (mean, across all concurrent requests)

/* 平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题 */

Transfer rate:          1.55 [Kbytes/sec] received

/* 网络上消耗的时间的分解,各项数据的具体算法还不是很清楚 */

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:       20  318 926.1     30    2954

Processing:    40 2160 1462.0   3034    3154

Waiting:       40 2160 1462.0   3034    3154

Total:         60 2479 1276.4   3064    3184

 

/* 下面的内容为整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中 50  的用户响应时间小于 3064 毫秒, 60  的用户响应时间小于 3094 毫秒,最大的响应时间小于 3184 毫秒 */

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

  50%   3064

  66%   3094

  75%   3124

  80%   3154

  90%   3184

  95%   3184

  98%   3184

  99%   3184

  100%   3184 (longest request)

 

更多信息

ab 不像 LR 那么强大,但是它足够轻便,如果只是在开发过程中想检查一下某个模块的响应情况,或者做一些场景比较简单的测试, ab 还是一个不错的选择——至少不用花费很多时间去学习 LR 那些复杂的功能,就更别说那 License 的价格了。

下面是 ab 的详细参数解释,大家有兴趣的可以研究一下,最近没有足够多的时间研究,如果哪位朋友有兴趣希望可以帮忙翻译一下每个参数的含义,有问题讨论也欢迎在这里回帖 ^_^

ab [ - A auth-username : password ] [ - c concurrency ] [ - C cookie-name = value ] [ - d ] [ - ecsv-file ] [ - g gnuplot-file ] [ - h ] [ - H custom-header ] [ - i ] [ - k ] [ - n requests ] [ - pPOST-file ] [ - P proxy-auth-username : password ] [ - q ] [ - s ] [ - S ] [ - t timelimit ] [ - Tcontent-type ] [ - v verbosity ] [ - V ] [ - w ] [ - x <table>-attributes ] [ - X proxy [: port ] ] [ - y<tr>-attributes ] [ - z <td>-attributes ] [http://] hostname [: port ]/ path

 

-A auth-username : password

Supply BASIC Authentication credentials to the server. The username and password are separated by a single : and sent on the wire base64 encoded. The string is sent regardless of whether the server needs it (i.e. , has sent an 401 authentication needed).

-c concurrency

Number of multiple requests to perform at a time. Default is one request at a time.

-C cookie-name = value

Add a Cookie: line to the request. The argument is typically in the form of a name = value pair. This field is repeatable.

-d

Do not display the "percentage served within XX [ms] table". (legacy support).

-e csv-file

Write a Comma separated value (CSV) file which contains for each percentage (from 1% to 100%) the time (in milliseconds) it took to serve that percentage of the requests. This is usually more useful than the 'gnuplot' file; as the results are already 'binned'.

-g gnuplot-file

Write all measured values out as a 'gnuplot' or TSV (Tab separate values) file. This file can easily be imported into packages like Gnuplot, IDL, Mathematica, Igor or even Excel. The labels are on the first line of the file.

-h

Display usage information.

-H custom-header

Append extra headers to the request. The argument is typically in the form of a valid header line, containing a colon-separated field-value pair (i.e. , "Accept-Encoding: zip/zop;8bit" ).

-i

Do HEAD requests instead of GET .

-k

Enable the HTTP KeepAlive feature, i.e. , perform multiple requests within one HTTP session. Default is no KeepAlive.

-n requests

Number of requests to perform for the benchmarking session. The default is to just perform a single request which usually leads to non-representative benchmarking results.

-p POST-file

File containing data to POST.

-P proxy-auth-username : password

Supply BASIC Authentication credentials to a proxy en-route. The username and password are separated by a single : and sent on the wire base64 encoded. The string is sent regardless of whether the proxy needs it (i.e. , has sent an 407 proxy authentication needed).

-q

When processing more than 150 requests, ab outputs a progress count on stderr every 10% or 100 requests or so. The -q flag will suppress these messages.

-s

When compiled in ( ab -h will show you) use the SSL protected https rather than the http protocol. This feature is experimental and very rudimentary. You probably do not want to use it.

-S

Do not display the median and standard deviation values, nor display the warning/error messages when the average and median are more than one or two times the standard deviation apart. And default to the min/avg/max values. (legacy support).

-t timelimit

Maximum number of seconds to spend for benchmarking. This implies a -n 50000 internally. Use this to benchmark the server within a fixed total amount of time. Per default there is no timelimit.

-T content-type

Content-type header to use for POST data.

-v verbosity

Set verbosity level - 4 and above prints information on headers, 3 and above prints response codes (404, 200, etc.), 2 and above prints warnings and info.

-V

Display version number and exit.

-w

Print out results in HTML tables. Default table is two columns wide, with a white background.

-x <table>-attributes

String to use as attributes for <table> . Attributes are inserted <table here > .

-X proxy [: port ]

Use a proxy server for the requests.

-y <tr>-attributes

String to use as attributes for <tr> .

-z <td>-attributes

String to use as attributes for <td>

 

2 ab也可以运行在windows中,如果在windows下安装apache,就可以在bin下找到ab.exe

直接就可以使用,不用依赖其他的dll

下面是我使用ab.exe 测试新浪一个页面的结果:

 

C:\Users\nickyjf\Desktop\useful>ab -n1000 -c100 http://sports.sina.com.cn/k/2011-05-24/12095590365.shtml 
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 sports.sina.com.cn (be patient) 
Completed 100 requests 
Completed 200 requests 
Completed 300 requests 
Completed 400 requests 
Completed 500 requests 
Completed 600 requests 
Completed 700 requests 
Completed 800 requests 
Completed 900 requests 
Completed 1000 requests 
Finished 1000 requests


Server Software:        Apache/2.0.63 
Server Hostname:        sports.sina.com.cn 
Server Port:            80

Document Path:          /k/2011-05-24/12095590365.shtml 
Document Length:        86680 bytes

Concurrency Level:      100 
Time taken for tests:   66.453 seconds 
Complete requests:      1000 
Failed requests:        0 
Write errors:           0 
Total transferred:      87135790 bytes 
HTML transferred:       86680000 bytes 
Requests per second:    15.05 [#/sec] (mean) 
Time per request:       6645.294 [ms] (mean) 
Time per request:       66.453 [ms] (mean, across all concurrent requests) 
Transfer rate:          1280.51 [Kbytes/sec] received

Connection Times (ms) 
              min  mean[+/-sd] median   max 
Connect:        1   56 398.3      2    3003 
Processing:    89 6331 2603.7   6293   14626 
Waiting:        2 1748 1485.9   1590    6284 
Total:         90 6388 2615.0   6302   14627

Percentage of the requests served within a certain time (ms) 
  50%   6302 
  66%   7121 
  75%   8435 
  80%   9193 
  90%   9231 
  95%   9385 
  98%  11549 
  99%  12459 
100%  14627 (longest request)

 

 

3 apache的ab工具也算是一种ddos攻击工具

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_865685.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

丑事网是史上SEO最差的网站

做过网站的人一定都知道SEO&#xff0c;即搜索引擎最佳化&#xff08;Search Engine Optimization&#xff09;&#xff0c;又称为搜索引擎优化&#xff0c;其主要工作是通过了解各类搜索引擎如何抓取互联网页面、如何进行索引以及如何确定其对某一特定关键词的搜索结果排名等技…

大型电子商务网站架构之--分布式可扩展数据库架构

近几年分布式成为热门的话题&#xff0c;也成为大型系统必备良药&#xff0c;而在数据库方面应用更加广泛。通过采用普通廉价的设备构建出高可用性和高扩展的集群目的。从而摆脱了大型设备的依赖&#xff0c;一个好的分布式数据库架构可以比较方便达到高可用性有可以达到向外扩…

网站的高性能架构

网站性能是客观的指标&#xff0c;可以具体体现到响应时间、吞吐量、并发数、性能计数器等技术指标。 1、性能测试指标 1.1 响应时间 指应用执行一个操作需要的时间&#xff0c;指从发出请求到最后收到响应数据所需要的时间。如下列出了系统常用的操作响应时间表. 操作 响应时…

用VSTS进行网站压力测试

VSTS提供了一个丰富、强大的工具平台&#xff0c;融合了软件开发领域的各个角色&#xff0c;涵盖软件开发生命周期的各个阶段&#xff0c;包括设计&#xff0c;开发&#xff0c;测试&#xff0c;管理&#xff0c;而这一整套构件的融会贯通&#xff0c;让它可以有效地改善软件开…

小白建站教程 腾讯云快速建站教程

相信不少的小伙伴都希望能有一个自己的网站&#xff0c;但是对于不会编程或者只有一点点技术的人来说自己搭建服务器、弄环境、写程序有点太困难了&#xff0c;有没有一种能让小白也能快速搭建自己网站的方法呢&#xff1f;今天就来给大家分享一下如何在腾讯云&#xff08;阿里…

网站是用mssql好还是mysql_mssql和mysql哪个好

MySQL和MSSQL各有各的优缺点&#xff0c;要根据项目实际情况来选择。MySQL是免费的数据库适合应用在小中型网站上&#xff0c;MSSQL是收费的商用数据库一般用在大型网站上。 MySQL与MSSQL哪个好 MySQL可以说是MSSQL的简化版本。理念相同&#xff0c;但MySQL的实现比MSSQL的需求…

搭载Ubuntu18.04的服务器的ASP.Net Core的搭建以及使用VS2017上传网站的学习

要在远程服务器Ubuntu18.04上运行ASP.Net&#xff0c;第一步需要搭建运行环境 主要参考&#xff1a;https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial#ubuntu 首先安装源 wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-p…

网站遇到Bytespider爬虫该怎么办?

早上打开网站&#xff0c;发现超级卡&#xff0c;以为是网速原因&#xff0c;调试了路由器无济于事&#xff0c;都说重启大法好&#xff0c;重启那就重启web服务试试&#xff0c;可惜依旧没用&#xff0c;不过重启的时候发现CPU彪到99&#xff0c;我还以为是被谁Doos了。 发现…

如何防止网站被侵入,如何防止网站被挂马,如何防止网站被入侵?

一&#xff1a;挂马预防措施&#xff1a; 1、建议用户通过ftp来上传、维护网页&#xff0c;尽量不安装asp的上传程序。 2、对asp上传程序的调用一定要进行身份认证&#xff0c;并只允许信任的人使用上传程序。这其中包括各种新闻发布、商城及论坛程 序&#xff0c;只要可以上传…

android学习笔记15--------------获取网站html

转载注明出处&#xff1a;袁方的技术博客 http://blog.csdn.net/yf210yfimport java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL;import junit.f…

电脑网站中有哪些有趣却不出众的小众网站呢

我们在使用电脑的时候会发现不少有趣的电脑网站&#xff0c;这些网站的名声并不出众&#xff0c;但是这些小众的网站却有很多有趣的故事和图片。我们在这些小众的网站上还可以看到一些世界上发生的一些有趣的、奇异的小故事&#xff0c;还有一张张美丽的图片在网站上展示出来。…

给网站添加“开放搜索描述“以适配浏览器的“站点搜索“

背景 要在一个常用网站搜索&#xff0c;想必大部分人会这样&#xff1a; 访问这个网站的的主页或者任意一个带搜索框的页面聚焦输入框&#xff0c;输入关键词并Enter 而如果一个网站适配了浏览器的"站点搜索"&#xff08;site search&#xff09;特性&#xff0c;…

Android开发时,那些相见恨晚的工具或网站!

本文来我在知乎话题Android开发时你遇到过什么相见恨晚的工具或网站&#xff1f;下的回答&#xff01; 在实际Android开发过程确实会有很多相见恨晚的工具或网站出现&#xff0c;下面是我自己的一些分享。 1、源码网站 https://github.com/googlesamples Android系统每次推出一…

用织梦创建本地网站通过Tomcat成功部署到Linux服务器详细教程(Ubuntu16.04)

用织梦创建本地网站成功部署到Linux服务器全过程详细教程&#xff08;Ubuntu16.04&#xff09; 织梦创建本地网站成功部署到Linux服务器详细教程&#xff08;Ubuntu16.04&#xff09; 本教程旨在帮助那些建网站小白如何从头搭建起本地网站并且最终上传到自己或公司的服务器上…

显示网站Alexa世界排名的代码

作者&#xff1a;佚名 转贴自&#xff1a; 苹果理想3dapple Alexa世界排名众多站长已经不会陌生了&#xff0c;今年将它炒的非常厉害&#xff0c;众多网站不论是拉广告还是做宣传都会以Alexa世界排名作为依据。因此&#xff0c;在这里西部E网&#xff08;weste.net&#xf…

关于我的个人网站(一)

这两天我中国丫头这个个人网站突然打不开了&#xff0c;空间是用的朋友的&#xff0c;大概是出什么问题了吧&#xff0c;反正也没有再去更新了&#xff0c;也没有问朋友原因&#xff0c;他也忙&#xff0c;也不能总是麻烦人家&#xff0c;关闭了就关闭了&#xff0c;早就有重新…

关于我的个人网站(二)

现在要说的就是中国丫头这个网站了&#xff0c;也是2003年九月份做的.... 点击这里进入

出来混迟早要还的-Alexa开始清算 国内作弊网站几乎全部落网

作者&#xff1a;周腥腥的博客 来源: 博客中国出来混迟早要还的,Alexa的报复行动开始了.Alexa的行动从2005年1月21日开始了......Alexa的作弊网站一个一个露出了原形.Alexa作弊最近一段时间已经成为的热门话题,作为一个相对权威排行,它肯定会尽可能的去阻止作弊,更不允许某些人…

如何在爱课程网站下载视频与课件

如何在爱课程网站下载视频与课件 如何下载视频与课件如何在MacOS中安装Python 最近要看些水声物理的东西&#xff0c;就必须掌握数学物理方法&#xff0c;可惜大学荒了这门手艺&#xff0c;只能重新啃啃书捡一捡&#xff0c;于是乎搜索了一下知乎&#xff0c;看到了如下链接&am…

提高网站访问速度的四个有效方法

通过站长工具查询能了解到&#xff0c;一些租用海外服务器的网站&#xff0c;特别是用香港服务器的网站&#xff0c;打开速度跟放在国内服务器的网站并无差异。放在海外服务器的网站&#xff0c;特别是香港服务器的网站&#xff0c;是如何做到网站速度快的&#xff1f;如果网站…