使用 ApacheBench 做网站压力测试

news/2024/5/9 12:41:46/文章来源:https://blog.csdn.net/weixin_34302798/article/details/92684512

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

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 和 -n 参数就可以了. 例如: 
./ab -c 100 -n 10000 http://127.0.0.1/index.php 
这个表示同时处理100个请求并运行10000次index.php文件. 
*/

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 [ -Aauth-username:password ] [ -cconcurrency ] [ -Ccookie-name=value ] [ -d ] [ -ecsv-file ] [ -ggnuplot-file ] [ -h ] [ -Hcustom-header ] [ -i ] [ -k ] [ -nrequests ] [ -pPOST-file ] [ -Pproxy-auth-username:password ] [ -q ] [ -s ] [ -S ] [ -ttimelimit ] [ -Tcontent-type ] [ -vverbosity] [ -V ] [ -w ] [ -x<table>-attributes ] [ -Xproxy[: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 aname=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 onstderr 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 andvery 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.), 2and 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>.

转载于:https://my.oschina.net/softwarechina/blog/146443

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

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

相关文章

7月国内网站流量统计:新浪和凤凰网竞争较大

IDC评述网(idcps.com)07月31日报道&#xff1a;跟据中国互联网协会-中国网站排名最新数据显示&#xff0c;截至2013年7月28日&#xff0c;国内网站独立访问量排名前五的仍旧是&#xff1a;百度、腾讯网、淘宝网、新浪网和凤凰网&#xff0c;如下图。如图所示&#xff0c;在7月份…

【笔记】网站加密认证

一、背景 (1)简介 当用户上网时&#xff0c;为了保证用户和服务器之间的信息传输不会泄漏&#xff0c;会对传输过程进行加密&#xff0c;防止泄密。 其流程如下&#xff1a; 1、当网站设置加密后会拥有证书&#xff0c;公钥锁&#xff0c;私钥。 2、当用户访问某个服务器&…

关于360网马扫描和网站安全狗网马扫描比较测评【转】

2019独角兽企业重金招聘Python工程师标准>>> 很多网站用户经常发现网站被植入后门程序&#xff0c;导致网站被黑客非法控制、非法利用&#xff0c;甚至整台服务器权限被控制。出现这种情况&#xff0c;通过人工来排查&#xff0c;需要一定的技术能力和工作量。因此需…

或使用命令行工具 appcmd.exe 为网站添加 mime 映射_“分子对接技术”之使用AutoDock进行半柔性对接教程...

文 / 利刃君微信ID / ziyuanliren666全文共3928字&#xff0c;推荐阅读时间10分钟。Autodock是一款开源的分子模拟软件&#xff0c;最主要应用于执行配体—蛋白分子对接。它由Scripps研究所的Olson实验室开发与维护&#xff0c;官方网址是http://autodock.scripps.edu/&#xf…

某国家大型考试网站安全漏洞测试 (二)

2019独角兽企业重金招聘Python工程师标准>>> Xss Dom型 对于这种安全问题&#xff0c;太复杂&#xff0c;得仔细分析页面和理解服务端的处理逻辑。就好比这次的安全测试&#xff0c;某一项功能的业务需求是考生一次考试只允许选择报考该考试的某一个职位&#xff0c…

网博士自助建站系统_阿里云ECS、轻量应用服务器、云虚拟主机、云速成美站自助建站系统该如何选择...

阿里云作为国内云计算行业的NO.1&#xff0c;用户数量非常的庞大经常在知乎看到朋友们问在阿里云那么多的建站产品里面该如何选择&#xff0c;这里老骥就对阿里云的几款主流的建站产品做一个简单的对比&#xff0c;不想看中间罗里吧嗦的可以直接看最后的总结。对比产品&#xf…

单页网站不是梦,几款国外的单页网站创建工具

单页网站已经流行很久了&#xff0c;受到很多人的喜爱。从立体动感的视差滚动效果和流畅的动画到固定和干净的菜单&#xff0c;你会发现单页网站的效果真的很酷&#xff01; 在这篇文章中&#xff0c;我们寻找了一些真正好用的单页网站创建工具分享给大家。这些工具对于那些想要…

IE10、IE11 User-Agent 导致的 ASP.Net 网站无法写入Cookie 问题

原文:IE10、IE11 User-Agent 导致的 ASP.Net 网站无法写入Cookie 问题你是否遇到过当使用一个涉及到Cookie操作的网站或者管理系统时&#xff0c;IE 6、7、8、9下都跑的好好的&#xff0c;唯独到了IE10、11这些高版本浏览器就不行了&#xff1f;好吧&#xff0c;这个问题码农连…

关于泰捷商城项目与如何做一个高可用的网站

2019独角兽企业重金招聘Python工程师标准>>> hi 各位&#xff0c; 上两周一直都在做泰捷商城这个项目。这个项目的目的就是卖泰捷出品的WEBOX。这是我第一次做有关电子商务的网站。各种头绪。其实原始需求很简单&#xff0c;只卖一件商品&#xff0c;每星期只卖一次…

linux上关闭tls1.0协议,NGINX禁用TLS1.0和TLS1.1使网站更安全

一、为什么要禁用 TLS1.0、TLS1.1&#xff1a;SSL 由于以往发现的漏洞&#xff0c;已经被证实不安全。而 TLS1.0 与 SSL3.0 的区别实际上并不太多&#xff0c;并且 TLS1.0 可以通过某些方式被强制降级为 SSL3.0。由此&#xff0c;支付卡行业安全标准委员会(PCI SSC)强制取消了支…

JSP 网络书签按钮聚合网站

1. http://www.jiathis.com/ JiaThis是一个提供网页地址收藏、分享及发送的WEB2.0按钮工具&#xff0c;网站的浏览者可以方便的分享到人人网、开心网、QQ空间、新浪微博等一系列社会化关系网络站点。 是一个网络书签按钮聚合网站&#xff0c;类似国外的Addthis。 JiaThis™“…

讨论标志设计的全英文论坛形式的网站--界面设计

转载于:https://www.cnblogs.com/kaixinniu/archive/2008/09/28/1301163.html

可进行JavaScript代码测试与调试的12个网站

概述&#xff1a;JavaScript是网站前端开发最为重要的一门编程语言&#xff0c;本文收集了能够在线测试与调试JavaScript代码的12个网站 1、JS Bin JS bin是一个为JavaScript和CSS爱好者们提供特定情况下的代码片段测试的网站。它可以让你和你的同伴合作调试代码。你可以在这里…

分享15款精美的免费 HTML5 网站模板

在过去的几年&#xff0c;网页设计和制作人员就已开始关注和使用 HTML5 了&#xff0c;如今 HTML5 得到了更加广泛的应用&#xff0c;国外有很多网站已使用 HTML5 技术制作。之前的文章和大家分享过精美的HTML5企业网站和HTML5个人网站&#xff0c;大家可以去欣赏一下这些作品。…

(转)Web自动化测试之12306火车票网站自动登录工具

原文地址&#xff1a;http://www.cnblogs.com/TankXiao/archive/2012/02/20/2350421.html还记得2011年春运&#xff0c;12306火车票预订网站经常崩溃无法登录吗。 今天我们就开发一个12306网站自动登录软件。 帮助您轻松订票通过前两篇博客Fiddler教程和HTTP协议详解&#xff0…

分享7个老师们常备的资源网站

教师较常用的网址&#xff0c;通常基本都是资源、通过自学形式的网址&#xff0c;这样的网址我们可以用于通过自学提升自己。 这儿就来分享7个教师常备的资源网&#xff0c;个个基本都是经典&#xff0c;一下子都给你哦。 1、我要自学网 较为知名的一个自学网站&#xff0c;这儿…

网站文件系统发展分布式文件系统fastDFS

网站文件系统发展 1、单机时代的图片服务器架构 初创时期由于时间紧迫&#xff0c;开发人员水平也很有限等原因。所以通常就直接在website文件所在的目录下&#xff0c;建立1个upload子目录&#xff0c;用于保存用户上传的图片文件。如果按业务再细分&#xff0c;可以在upload目…

网站前端_EasyUI.基础入门.0005.使用EasyUI Accordion组件的最佳姿势?

1. 基础的手风琴<div id"a" class"easyui-accordion" data-options"width:500,height:300"><div data-options"iconCls:icon-ok,title:about,bodyCls:accordion_padding"><h3 style"color:#0099FF;">Acco…

Jekyll – 基于纯文本的开源静态网站 博客系统

Jekyll 是一个开源的静态网站 & 博客生成工具&#xff0c;类似 WordPress。但是和 WordPress 又有很大的不同&#xff0c;原因是 Jekyll 只是一个生成静态网页的工具&#xff0c;不需要数据库支持。但是可以配合第三方服务&#xff0c;例如disqus。最关键的是 Jekyll 可以免…

给你一个网站,你该如何测试?你需要记住这4条法则!

我想大多数开始进行web端页面测试的人&#xff0c;一开始会的都是在页面上点点点&#xff0c;然后一看到页面上有什么图片失效啊&#xff0c;页面遮挡就觉得是找到了大bug&#xff1b;一开始我也是这样&#xff0c;尽管我很谨慎&#xff0c;很仔细&#xff0c;把页面上的每一个…