- Comparison of Outputs
- Sequential Test Cases for Dynamic Pages
- Preparation for Testing Dynamic Pages
- Testing Multiple URLs Concurrently
- Testing Our Sample Application
- Apache Bench - Environment Setup
- Apache Bench - Overview
- Apache Bench - Home
Apache Bench Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Apache Bench - Quick Guide
Apache Bench - Overview
业绩测试证明对企业的成功至关重要。 业绩不佳的地点不仅面临财政损失,而且有时还会导致法律影响。
没有人想在重要的在线互动中,如采购、在线测试、支付账单等,建立低效、不可靠的网站。 随着互联网的广泛使用,各种替代措施是巨大的。 失去客户比获得客户更容易,而业绩是关键的游戏变化者。
Need for a Load Testing Tool
如果我们能够理解需要一种装载检测工具,它将给我们使用这一工具的理由和动机。 一些著名的商业网站在接待大量游客时遭遇严重故障。 电子商务网站大量投资于广告活动,但不投资于Load检测。 因此,当这一营销带来交通时,它们未能确保最佳的系统性能。
忽略负荷测试的另一个常见例子就是在WordPress网站上“建立链接”。 因此,在网站的部署之前装设试验或应用,是一个好的想法。 在对公路进行更为详细的测试之前,迅速为项目确定最佳情景是明智的。
What is Apache Bench?
阿帕奇科(ab)是阿帕奇组织的基准超文本传输协议网络服务器的工具。 虽然该软件旨在衡量阿帕奇网络服务器的运行情况,但也可用于测试任何其他同样好的网络服务器。 有了这一工具,你可以很快地知道,每二个网站服务器中有多少申请能够服务。
Features of Apache Bench
让我们看到阿帕奇科法官的重要特点和限制。 特征和限制如下:
这是一种开放源软件,可以自由使用。
这是一个简单的指挥线计算机程序。
这是一个依赖平台的工具。 这就意味着,可以同样地在短链氯化石蜡/Unix或Windows服务器上援引。
该系统只能对网络服务器――吉大港航空公司或高港邮局――进行负荷和性能测试。
这并非可以轻视。
阿帕奇科法官只使用一个运行系统,而不论是否一致(按国旗排列)。 因此,在对高功能服务器进行基准时,阿帕奇科法官的单一实例本身就可以成为瓶颈。 为了完全饱和卢爱阵的目标,如果你的服务器有多个处理器芯,最好同时使用阿帕奇科的额外案例。
Precaution
你们需要认识到,阿帕奇科法官没有指令在进行测试时增加特别的间隔。 因此,使用ab进行装载测试相当于拒绝服务攻击。 建议,如果您在很长一段时间内将进行重载测试,则通知并事先征得您的甚高频服务提供者的同意。 他们将给你一个适当的间隔时间,或者把你的节点转用于负荷检测任务。
第二,如果你不断测试第三人的网站,而且要等很长时间才能从您的科索沃警察部队学习阿帕奇科(成为测试节点),那么,你的科索沃警察部队公共IP有可能永久被第三人网站阻断。 在这种情况下,你将无法与同一个IP连接该网站。 但是,如果你真的希望今后能够与网站连接,唯一的解决办法是同目标网站的系统管理人交谈,或者在您的甚高频服务提供者的帮助下,建立一个有不同IP的服务器的新案例。
在发出警告后,请允许我向您保证,本辅导中的所有测试都足够安全,而且系统管理人员通常称之为“系统滥用”做法。
Apache Bench - Environment Setup
在本章中,我们将指导你如何为阿帕奇科斯·普切斯多斯设立环境。
System Requirement
Instalpng Apache Bench
阿帕奇科法官是一个独立应用程序,在阿帕奇网络服务器安装上没有附属设施。 以下是安装阿帕奇科法官的两步工作。
<1>Step 1——更新包裹数据库。
# apt-get update
请注意,在终端指挥之前的编号意味着根本使用者正在发出这一指挥。
Step 2-Install apache2 utils Pack to access to Papaque.
# apt-get install apache2-utils
现在安装了阿帕奇科。 如果你想测试同一个甚高频站的网络应用,那么仅仅安装阿帕奇网络服务器就足够了。
# apt-get install apache2
作为一个阿帕奇公用事业公司,阿帕奇科在安装阿帕奇网络服务器时自动安装。
Verifying Apache Bench Installation
我们现在看如何核查阿帕奇科公司的安装。 以下代码将有助于核查安装情况——
# ab -V
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/
当你看到上述终端产出时,这意味着你成功安装了阿帕奇科。
Creating a Privileged Sudo User
从安全观点看,系统管理人建立传道用户而不是作为根基的工作是一种良好做法。 我们将为此目的建立一个称为测试的测试用户——
# useradd -m -d /home/test -g sudo test
让我们为新用户确定密码——
# passwd test
该系统将促使用户测试出现新的密码。 你可以进入一个简单的密码,因为我们只是测试,而不是部署到生产服务器。 通常,传闻指挥将促使你提供传闻用户密码;建议不要使用复杂的密码,因为这一过程变得麻烦。
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
Testing Apache.org Website
本节将测试阿帕奇网站。 让我们首先转向代人用户测试——
# su test
首先,我们将测试阿帕奇组织网站
$ ab -n 100 -c 10 https://www.apache.org/
此处为-n,为基准会议提出请求的次数。 缺省只是提出单一要求,通常会导致非代表性的基准结果。
-c> 是一致的,是指多次要求随时执行的请求。 违约是一次请求。
因此,在这次测试中,阿帕奇科法官将向阿帕奇组织服务器提出100项申请,同意10项。
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking www.apache.org (be patient).....done Server Software: Apache/2.4.7 Server Hostname: www.apache.org Server Port: 443 SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256 Document Path: / Document Length: 58769 bytes Concurrency Level: 10 Time taken for tests: 1.004 seconds Complete requests: 100 Failed requests: 0 Total transferred: 5911100 bytes HTML transferred: 5876900 bytes Requests per second: 99.56 [#/sec] (mean) Time per request: 100.444 [ms] (mean) Time per request: 10.044 [ms] (mean, across all concurrent requests) Transfer rate: 5747.06 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 39 46 30.9 41 263 Processing: 37 40 21.7 38 255 Waiting: 12 15 21.7 13 230 Total: 77 86 37.5 79 301 Percentage of the requests served within a certain time (ms) 50% 79 66% 79 75% 80 80% 80 90% 82 95% 84 98% 296 99% 301 100% 301 (longest request)
在进行了第一次试验之后,很容易认识到这一指挥系统的使用方式,情况如下:
# ab [options .....] URL
,
Understanding the Output Values
我们需要理解不同的衡量标准,以了解各种产出价值。 名单如下:
Server Port 这是连接起来的港口。 如果在指挥线上没有港口,则在http://www.un.org/www.un.org上将港口停泊到80个,在https上将达443个。
<SSL/TLS Protocol-> 这是客户和服务器之间谈判达成的协议参数。 更正应只对原文提出。
Complete Request 收到的成功答复数目。
Quick Analysis of the Load Testing Output
在了解了从b指挥部获得的产出价值标题之后,让我们努力分析并理解我们初步检验的产出价值——
阿帕奇组织正在使用自己的网络服务器软件——阿帕奇(2.4.7)。
服务器在443港通过https收听。 如果是http://www.fault.org。
转交的数据总额为58769份,涉及100项申请。
1 004秒完成测试。 没有失败的请求。
每秒——99.56。 这个数字相当高。
每一份请求时间——100 444 ms(同时10项请求)。 因此,在所有要求中,它为100.444 ms/10 = 10.044 ms。
转账率——1338.39 [Kbytes/sec] 收到。
关于时间统计,你可以指出,许多请求不得不等待几秒。 这可能是由于一个pache网络服务器在等待点提出申请。
在第一次测试中,我们测试了由不同服务器主办的申请(即www.apache.org)。 在教学的稍后部分,我们将测试我们在同一个服务器上主办的网络应用样本,我们将从这些服务器中进行 a测试。 这有助于学习和示范目的。 理想的情况是,对于准确测量而言,东道方的点子和检测线应当有所不同。
为了更好地学习,你应当比较和观察我们在本教学阶段前进时,不同情况下的产出价值如何变化。
Plotting the Output of Apache Bench
在此,我们将确定相关成果,以了解服务器在请求数量增加时需要多少时间。 为此,我们将在先前的指挥中增加-g选择,然后添加档案名称(如数据),保存目录数据。
$ ab -n 100 -c 10 -g out.data https://www.apache.org/
我们现在看out.data。 在此之前,我们就建立了一个阴谋。
$ less out.data
starttime seconds ctime dtime ttime wait Tue May 30 12:11:37 2017 1496160697 40 38 77 13 Tue May 30 12:11:37 2017 1496160697 42 38 79 13 Tue May 30 12:11:37 2017 1496160697 41 38 80 13 ...
我们现在可以理解out.datafile——栏目。
seconds - 成为起算时间,但采用“简讯”格式(日期-d @1496160697 恢复起算产出)。
<ttime 这是全时(即时和假日、数学时间=小时+时间)。
对于这些多件物品彼此关联的地形图化,要看以下图像:
如果我们在码头上工作,或者在没有制图的情况下工作,gnuplot就是一个很大的选择。 我们将通过采取以下步骤迅速理解这一点。
让我们安装和发射装置——
$ sudo apt-get install gnuplot $ gnuplot
G N U P L O T Version 4.6 patchlevel 6 last modified September 2014 Build System: Linux x86_64 Copyright (C) 1986-1993, 1998, 2004, 2007-2014 Thomas Wilpams, Copn Kelley and many others gnuplot home: http://www.gnuplot.info faq, bugs, etc: type "help FAQ" immediate help: type "help" (plot window: hit h ) Terminal type set to qt gnuplot>
由于我们正在努力处理终点站,并假设无法提供图象,我们可以选择将在ASCII中输出到终点站。 这有助于我们了解我们阴谋如何看待这一快速工具。 我们现在为ASCII地块做准备。
gnuplot> set terminal dumb
Terminal type set to dumb Options are feed size 79, 24
由于我们的格恩普车终点站现已准备就绪,可供ASCII号地块使用,让我们从out.data/b>文档中规划数据。
gnuplot> plot "out.data" using 9 w l
1400 ++-----+------+-----+------+------+------+------+-----+------+-----++ + + + + + + +"out.data" using 9 ****** + | | 1200 ++ ******************************************** | ******************* | 1000 ++ * ++ | * | | * | 800 ++ * ++ | * | | * | 600 ++ * ++ | * | | * | 400 ++ * ++ | * | 200 ++ * ++ | * | +**** + + + + + + + + + + 0 ++-----+------+-----+------+------+------+------+-----+------+-----++ 0 10 20 30 40 50 60 70 80 90 100
我们从第9栏中规划了有关申请数目的时间、总时间(以黑体计)。 我们可以注意到,对于最初的10项请求,今后30项请求(从10项<><>第至40项>>>>)的合计时间已增加到1100万立方米。 你们的阴谋必须根据out.data加以区别。
Testing Our Sample Apppcation
在前一章,我们理解阿帕奇科法官对第三方网站进行测试的基本用途。 在本节中,我们将利用这一工具测试我们自己服务器上的网络应用。 为了尽可能使教学自足,我们选择为示范目的安装假日应用程序;根据你的专业知识水平,你可以选择像PHP或Ruby等其他语言。
Instalpng Python
一般说来,甲型六氯环己烷是通过违约安装在六氯环己烷服务器上。
Instalpng Bottle Framework and Creating a Simple Apppcation
Bottle is a microframework written in python for estabpshing web apppcation, and pip is a python Pack Manager. 安装船坞的以下指挥类型:
$ sudo apt-get install python-pip $ sudo pip install bottle
现在,让我们创立一个小型的博爱应用。 为此,制作目录并在内部迁移——
$ mkdir webapp $ cd webapp
我们将在网络应用程序目录内制作一个新的版面,app.py。
$ vim app.py
现在,在笔卷中写以下代码:
from bottle import Bottle, run app = Bottle() @app.route( / ) @app.route( /hello ) def hello(): return "Hello World!" run(app, host = localhost , port = 8080)
当你添加上述内容时,可以节省和关闭档案。 在挽救了档案之后,我们可以操作假装,以启动申请。
$ python app.py
Bottle v0.12.7 server starting up (using WSGIRefServer())... Listening on http://localhost:8080/ Hit Ctrl-C to quit.
这一产出显示,我们的申请正在东道地方机器上运行http:// localhost。 80。
让我们检查一下,我们是否对吉大港山区的请求做出适当回应。 由于这一终点站不能在不放弃服务的情况下作出任何投入,我们需要与另一个终点站一道向我们的甚高频定位。 在与另一个终点站一起向甚高频系统投放之后,你可以在新终端打下以下代码,从而对你的申请采取行动。
$ lynx http://localhost:8080/
Lynx是一条指挥线浏览器,通常安装在Debian和Utub等各种含水层分布中。 如果你看到以下产出,那就意味着你正在做罚款。
如果你看到上述产出,这意味着我们的申请是活的,可以进行测试。
Testing the Apppcation with Developmental Web Server
请注意,Ab有ug,无法在当地试验申请。 因此,我们将把东道方从当地托管人改为用户档案中的127.0.1。 因此,档案将改为:
from bottle import Bottle, run app = Bottle() @app.route( / ) @app.route( /hello ) def hello(): return "Hello World!" run(app, host = 127.0.0.1 , port = 8080)
现在,让我们通过在沿风轴指挥的同一个终点站打下以下指挥——来检验我们的期望。
$ ab -n 100 -c 10 http://127.0.0.1:8080/hello
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient).....done Server Software: WSGIServer/0.1 Server Hostname: 127.0.0.1 Server Port: 8080 Document Path: /hello Document Length: 12 bytes Concurrency Level: 10 Time taken for tests: 0.203 seconds Complete requests: 100 Failed requests: 0 Total transferred: 16500 bytes HTML transferred: 1200 bytes Requests per second: 493.78 [#/sec] (mean) Time per request: 20.252 [ms] (mean) Time per request: 2.025 [ms] (mean, across all concurrent requests) Transfer rate: 79.56 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 0 Processing: 1 6 28.2 2 202 Waiting: 1 6 28.2 2 202 Total: 1 6 28.2 2 202 Percentage of the requests served within a certain time (ms) 50% 2 66% 2 75% 2 80% 2 90% 2 95% 2 98% 202 99% 202 100% 202 (longest request)
第一个终点站的产出为(100次)如下:
... 127.0.0.1 - - [10/Jun/2017 04:30:26] "GET /hello HTTP/1.0" 200 12 127.0.0.1 - - [10/Jun/2017 04:30:26] "GET /hello HTTP/1.0" 200 12 127.0.0.1 - - [10/Jun/2017 04:30:26] "GET /hello HTTP/1.0" 200 12 ...
你们可以观察,与最初的测试相比,乙成果的各种价值是如何变化的。
Testing the Apppcation with a Multi-Threaded Web Server
在以往的反射测试中,我们使用了布特框架中捆绑的违约网络服务器。
现在,我们将改变单一阅读的缺省网络服务器,配备多读。 因此,让我们安装一个多读的网络服务器图书馆,如cherrypy或gunienta,并指示Bottle使用。 我们选择了枪枝,用于这里的示威目的(你也可以选择其他东西)。
$ sudo apt-get install gunicorn
并修改档案,即从违约网络服务器改为枪角。
... run(server = gunicorn ...) ...
让我们在第二个终点站测试这一数据。
$ ab -n 100 -c 10 http://127.0.0.1:8080/hello
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient).....done Server Software: gunicorn/19.0.0 Server Hostname: 127.0.0.1 Server Port: 8080 Document Path: /hello Document Length: 12 bytes Concurrency Level: 10 Time taken for tests: 0.031 seconds Complete requests: 100 Failed requests: 0 Total transferred: 17200 bytes HTML transferred: 1200 bytes Requests per second: 3252.77 [#/sec] (mean) Time per request: 3.074 [ms] (mean) Time per request: 0.307 [ms] (mean, across all concurrent requests) Transfer rate: 546.36 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 0.9 0 4 Processing: 1 2 0.7 3 4 Waiting: 0 2 0.8 2 3 Total: 2 3 0.6 3 5 WARNING: The median and mean for the initial connection time are not within a normal deviation These results are probably not that repable. WARNING: The median and mean for the processing time are not within a normal deviation These results are probably not that repable. Percentage of the requests served within a certain time (ms) 50% 3 66% 3 75% 3 80% 3 90% 4 95% 5 98% 5 99% 5 100% 5 (longest request)
观察每份请求如何从493份增加到3252份。 它意味着玉米适合成为花.的生产服务器。
Testing Multiple URLs Concurrently
在本章中,我们将学会如何同时测试多种URLs。 为此,我们将需要编辑我们的申请档案,用数字显示两个卢比。
from bottle import Bottle, run app = Bottle() @app.route( / ) @app.route( /hello1 ) def hello(): return "Hello World! It is first URL." @app.route( /hello2 ) def hello(): return "Hello World! It is second URL." run(app,server = gunicorn ,host = 127.0.0.1 , port = 8080)
Creating a Simple Shell Script
你可以这样做,用多条手提来打字。 建立档案测试。
ab -n 100 -c 10 http://127.0.0.1:8080/hello1 ab -n 100 -c 10 http://127.0.0.1:8080/hello2
当你添加上述内容时,“拯救和关闭”档案。 起诉——
chmod u+x test.sh
让我们现在掌握文字——
./test.sh
为了避免重复和明确的目的,我们将只显示b产出的相关内容,用斜线标明遗漏了哪些部分,如下文所示。
Output
. . . Document Path: /hello1 Document Length: 732 bytes Concurrency Level: 10 Time taken for tests: 0.040 seconds Complete requests: 100 Failed requests: 0 Non-2xx responses: 100 Total transferred: 90000 bytes HTML transferred: 73200 bytes Requests per second: 2496.13 [#/sec] (mean) Time per request: 4.006 [ms] (mean) Time per request: 0.401 [ms] (mean, across all concurrent requests) Transfer rate: 2193.87 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.8 0 3 Processing: 1 3 1.0 4 5 Waiting: 0 3 1.2 4 4 Total: 1 4 0.6 4 5 WARNING: The median and mean for the processing time are not within a normal deviation These results are probably not that repable. . . .
Shell Script to Save the Apache Bench Output to a File
你可以节省阿帕奇科法官的档案,用多条电话制作一张彩票。 每一行的结尾处设一个&,使指挥处于背景之下,让下一个指挥机构开始执行。 您也希望将产出转至每个尿液的档案,使用和提炼;档案名称和大体。 例如,我们的档案测试。
$ ab -n 100 -c 10 http://127.0.0.1:8080/hello1 > test1.txt & $ ab -n 100 -c 10 http://127.0.0.1:8080/hello2 > test2.txt &
这里,test1.txt和test2.txt 这些档案是为了节省产出数据。
您可以核实,上述文字创造了两个档案,即测试1.txt和测试2.txt,其中包含了相关URLs的副产品——
$ ls -l
Output
... -rw-r--r-- 1 root root 5225 May 30 12:11 out.data -rwxr--r-- 1 root root 118 Jun 10 12:24 test.sh -rw-r--r-- 1 root root 1291 Jun 10 12:31 test1.txt -rwxr--r-- 1 root root 91 Jun 10 13:22 test2.sh -rw-r--r-- 1 root root 1291 Jun 10 12:31 test2.txt ...
Watch-out Situation
在使用禁忌时,应提醒大家注意没有警告的失败考验。 例如,如果你检查一桩错误的URL,你可能会获得类似于以下内容的东西(我们故意改变这里的港口)。
$ ab -l -r -n 100 -c 10 -k -H "Accept-Encoding: gzip, deflate" http://127.0.0.1:805/
Output
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient).....done Server Software: Server Hostname: 127.0.0.1 Server Port: 805 Document Path: / Document Length: Variable Concurrency Level: 10 Time taken for tests: 0.002 seconds Complete requests: 100 Failed requests: 150 (Connect: 0, Receive: 100, Length: 0, Exceptions: 50) Keep-Apve requests: 0 Total transferred: 0 bytes HTML transferred: 0 bytes Requests per second: 44984.26 [#/sec] (mean) Time per request: 0.222 [ms] (mean) Time per request: 0.022 [ms] (mean, across all concurrent requests) Transfer rate: 0.00 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 0 0 0.2 0 0 Waiting: 0 0 0.0 0 0 Total: 0 0 0.2 0 0 Percentage of the requests served within a certain time (ms) 50% 0 66% 0 75% 0 80% 0 90% 0 95% 0 98% 0 99% 0 100% 0 (longest request)
Preparation for Testing Dynamic Pages
在本章中,我们将理解测试动态页面所需的准备工作。 服务器边动态网页是网页,其施工由应用服务器处理服务器边文字控制。 沥青板只能对服务器边动态网页进行负荷测试。
Concurrency Level and the Total Number of Requests
费用数额应低于请求总数。
$ ab -l -r -n 30 -c 80 -k -H "Accept-Encoding: gzip, deflate" http://127.0.0.1:8000/
ab: Cannot use concurrency level greater than total number of requests Usage: ab [options] [http[s]://]hostname[:port]/path
Use of Flags
在本节中,我们将描述使用某些重要旗帜和指挥。 我们将以互换的方式使用术语、选择和旗帜。
Verbose -v
如果存在多种失败的请求,则可以采用ver合和 de。 装载测试失败的一个共同迹象是,测试速度非常快,因此,每秒有相当多的要求。 但这将是一个错误的基准。 为了查明成功或失败之处,你可以采用-v 2备选办法,将每一反应的身体和头盔移至终端产出。 指挥显示使用案件之后——
$ ab -n 1 -v 2 http://www.generic-example-URL.com/
LOG: header received: HTTP/1.0 200 OK … Content-Length: 2548687
当然,如果你正在测试可变的答复,或者在出现任何错误时退回到非200份吉大港山区规则,那么你就应当忽视与-l备选办法的长时间核对。 不久,我们将在随后各章中推出一个网络版应用程序,届时我们将看到非200个吉大港山区。
Keep-apve -k
当客户发出“吉卜赛人”申请时,与服务器连接,服务器发出回复,联系在发出请求后关闭。 这一周期继续按每项要求进行。 然而,随着持续经营环境(也称为长期联系),客户保持基本的结核病防治联系,以促进多重要求和反应;这消除了本来会存在的缓慢而昂贵的连接初始化时间。
Variable document length -l
如果网页长度各异,则请使用-l。 阿帕奇科法官没有报告答复时间不固定的错误。 这对于动态网页是有用的。
Use of option -r
如何强迫放弃,以免出现错误? 请选择-r。 如果没有这一选择,一旦任何请求打上了计票错误,您的测验即可中断。 然而,由于这一选择,在失败的错误标题中将报告错误,但测试将持续到尾声。
Use of option -H
这一选择用来增加任意头盔。 该论点通常以有效的主线的形式提出,其中包含一个与殖民地相隔的外地价值配对(即“Accept-Encoding:zip/zop;8bit”)。
Use of option -C
在下一节中,我们将详细了解如何结合使用厨师价值的选择,即-C方案,使用上述选择。 “C”方案通常采用 姓名 = 数值 等形式。 这一领域可以重复。
Using Session Cookie with Apache Bench
为了了解如何使用阿帕奇科法官的厨师,我们需要一个网页,试图建立一个厨师。 一个很好的例子就是网络2版应用程序,这是一个星号网络框架。
Instalpng web2py
我们将迅速安装另一个电灯光网。 你们可以更多地了解如何在
。一般来说,在乌班图和德比亚服务器上安装了灰尘。 因此,已经满足了成功运行网络2版的要求。
然而,我们需要安装自动包裹,从我们将下载的日卷中提取网络2py的源文档——
$ sudo apt-get update $ sudo apt-get install unzip
让我们从该项目的网站获取网络2版框架。 我们将把这段话下载到我们的家里。
$cd ~ $ wget http://www.web2py.com/examples/static/web2py_src.zip
现在,我们可以揭开我们刚刚下载的档案,并在内部移动。
$ unzip web2py_src.zip $ cd web2py
为了管理网吧,你不需要安装。 一旦你在网上目录内,你可以通过打字以下指挥员来管理:
$python web2py.py
如果一切都取得成功,你将看到以下产出:请你选择行政倡议的密码。
web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2017 Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Database drivers available: sqpte3, imappb, pymysql, pg8000 WARNING:web2py:GUI not available because Tk pbrary is not installed choose a password: please visit: http://127.0.0.1:8000/ use "kill -SIGTERM 23904" to shutdown the web2py server
然而,你们需要认识到,只有当地机器才能进入启动的网络接口。
从产出来看,你可以理解,为了停止网络服务器,你必须把“CTRL-C”分类在即时终端。 另一方面,为了停止在另一个终端站安装与同一甚高频有关的网络2py服务器,你可以插入指挥杀人——SIGTERM <PID>在哪里和带;PID>是网络2py服务器的工序识别,在这种情况下是23904。
Session Cookie from web2py
如果只有用户录音带才能进入一个网页,但不能直接从标识页上查取,在这种情况下,你可以使用-C国旗。 这一旗帜界定了指挥的 co。 但是,你们必须从一次有效的会议上获得本届会议的识别标志。 如何做到这一点? 各种在线辅导员将指导你使用 Chrome(Catherine)浏览器开发工具。 但是,在我们试验案例中,由于申请只能在指挥线上提供,我们将利用lyn牛获得价值。
让我们首先获得一届会议的表象价值。 开放另一个终点站和以下指挥类型:
$ lynx http://127.0.0.1:8000/
针对上述指挥,林克斯将请您同意接受网络2py服务器的 co,如下图所示。
注:在打字之前, co的数值为y接受 co。 现在,终端站将与以下图像相类似:终端网站!
在获得了厨师的价值后,我们现在将进行 a测试。 为此,我们必须打开第三个终点站(见下图)——
现在,让我们在第三个终点站使用——C国旗——
$ ab -n 100 -c 10 -C session_name = 127.0.0.1-643dad04-3c34 http://127.0.0.1:8000/
Output
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient).....done Server Software: Rocket Server Hostname: 127.0.0.1 Server Port: 8000 Document Path: / Document Length: 66 bytes Concurrency Level: 10 Time taken for tests: 0.051 seconds Complete requests: 100 Failed requests: 0 Non-2xx responses: 100 Total transferred: 27700 bytes HTML transferred: 6600 bytes Requests per second: 1968.12 [#/sec] (mean) Time per request: 5.081 [ms] (mean) Time per request: 0.508 [ms] (mean, across all concurrent requests) Transfer rate: 532.39 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 1 2 0.9 2 4 Processing: 0 3 0.9 3 5 Waiting: 0 2 1.1 2 4 Total: 4 5 0.7 5 7 Percentage of the requests served within a certain time (ms) 50% 5 66% 5 75% 5 80% 6 90% 6 95% 6 98% 7 99% 7 100% 7 (longest request)
从上述产出来看,我们注意到几点。 第一,网络2py使用
网络服务器。 我们还注意到,除了先前讨论的产出标题外,我们还正在获得“Non-2xx”答复。 总的来说,Http协议是对使用回复法的一项要求的回应,200号编内的任何东西都意味着“kay”,其余部分则与一些问题相对应。 例如,400个是资源方面的错误,例如404个没有创建的档案。 500个与服务器错误相对应。 就本案而言,除非我们采用“C”方案,否则任何地方都不存在错误。 可以用已经描述的“l”办法加以压制。Checking Admin Page
在本节中,我们将了解如何检查行政网页。 为了比较起见,让我们测试网络2py应用软件中的另一种URL。
$ ab -n 100 -c 10 session_name = 127.0.0.1-643dad04-3c34 http://127.0.0.1:8000/admin
Output
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient).....done Server Software: Rocket Server Hostname: 127.0.0.1 Server Port: 8000 Document Path: /admin Document Length: 8840 bytes Concurrency Level: 10 Time taken for tests: 2.077 seconds Complete requests: 100 Failed requests: 0 Total transferred: 926700 bytes HTML transferred: 884000 bytes Requests per second: 48.14 [#/sec] (mean) Time per request: 207.749 [ms] (mean) Time per request: 20.775 [ms] (mean, across all concurrent requests) Transfer rate: 435.61 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 3.2 0 12 Processing: 62 204 52.2 199 400 Waiting: 61 203 52.0 199 400 Total: 62 205 54.3 199 411 Percentage of the requests served within a certain time (ms) 50% 199 66% 211 75% 220 80% 226 90% 264 95% 349 98% 381 99% 411 100% 411 (longest request)
http://127.0.0.1:8000/。 差异巨大。
Using Timepmit Option
一般来说,时间限制选择是一种trick。 让我们从
是相当解释性的。-t timepmit Maximum number of seconds to spend for benchmarking. This imppes a -n 50000 internally. Use this to benchmark the server within a fixed total amount of time. Per default there is no timepmit.
让我们以这一选择进行试验。 我们将在产出完成之后注意到我们的意见——
$ ab -n 100 -c 10 -t 60 http://127.0.0.1:8000/
Output
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient) Completed 5000 requests Completed 10000 requests Completed 15000 requests Completed 20000 requests Completed 25000 requests Completed 30000 requests Completed 35000 requests Completed 40000 requests Completed 45000 requests Completed 50000 requests Finished 50000 requests Server Software: Rocket Server Hostname: 127.0.0.1 Server Port: 8000 Document Path: / Document Length: 66 bytes Concurrency Level: 10 Time taken for tests: 22.547 seconds Complete requests: 50000 Failed requests: 0 Non-2xx responses: 50000 Total transferred: 13850000 bytes HTML transferred: 3300000 bytes Requests per second: 2217.61 [#/sec] (mean) Time per request: 4.509 [ms] (mean) Time per request: 0.451 [ms] (mean, across all concurrent requests) Transfer rate: 599.88 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 2 0.8 2 8 Processing: 0 2 3.2 2 218 Waiting: 0 2 3.2 2 218 Total: 2 4 3.1 4 220 Percentage of the requests served within a certain time (ms) 50% 4 66% 4 75% 4 80% 5 90% 5 95% 5 98% 7 99% 8 100% 220 (longest request)
产出显示这一选择超过了-n选择中规定的要求数量,并且继续满足50K的要求。 然而,由于这些请求的处理速度非常快,因此,一旦达到50克标记,就立即终止了b,即在22秒之内(见用于测试的标注时间)。
http://127.0.0.1:8000/。 (假设是我们的网络2py应用程序)或诸如https://www.apache.org/等第三方网站,都注意到统计数据的差异。
Checkpst Before Performing the Load Test
有一些检查将有助于你成功进行测试,准确衡量业绩。 在进行装载测试之前考虑以下条件:
确保不装上任何外衣模块。
为了避免TCP/IP港的穷尽,通常在你转向另一个旁观器之前要等2-3分钟。
确保同时连接的数量低于阿帕帕奇工人校对。
如果阿帕奇或皮星坠毁,在进行另一场测试之前,你应更换服务器。
Sequential Test Cases for Dynamic Pages
在本章中,我们将介绍-n和-c与重要旗帜之间的各种组合,以便逐步增加网站服务器上的工作量。
你们应主要侧重于如何改变你增加负荷的以下指标——
Requests per second
Connection Times (ms)
Percentage of the requests served within a certain time (ms)
当服务器开始 st忙时,你还应注意到门槛值,你开始提出失败的要求。
1 Concurrent User Doing 100 Page Hits
让我们由一个用户——做100个连续的页数。
$ ab -l -r -n 100 -c 1 -k -H "Accept-Encoding: gzip, deflate" http://127.0.0.1:8000/
Output
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient).....done Server Software: Rocket Server Hostname: 127.0.0.1 Server Port: 8000 Document Path: / Document Length: Variable Concurrency Level: 1 Time taken for tests: 0.045 seconds Complete requests: 100 Failed requests: 0 Non-2xx responses: 100 Keep-Apve requests: 0 Total transferred: 27700 bytes HTML transferred: 6600 bytes Requests per second: 2206.24 [#/sec] (mean) Time per request: 0.453 [ms] (mean) Time per request: 0.453 [ms] (mean, across all concurrent requests) Transfer rate: 596.80 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 0 0 0.0 0 0 Waiting: 0 0 0.0 0 0 Total: 0 0 0.0 0 1 Percentage of the requests served within a certain time (ms) 50% 0 66% 0 75% 0 80% 0 90% 1 95% 1 98% 1 99% 1 100% 1 (longest request)
5 Concurrent Users Each Doing 10 Page Hits
该案相当于一个月约50 000+点击的网站高峰负荷。
$ ab -l -r -n 10 -c 5 -k -H "Accept-Encoding: gzip, deflate" http://127.0.0.1:8000/
在随后的以下产出中,我们将为清晰起见而分拨共同首长。
Output
... Requests per second: 2009.24 [#/sec] (mean) Time per request: 2.488 [ms] (mean) Time per request: 0.498 [ms] (mean, across all concurrent requests) Transfer rate: 543.52 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 0.5 1 2 Processing: 0 1 0.5 1 2 Waiting: 0 1 0.5 1 1 Total: 2 2 0.4 3 3 ERROR: The median and mean for the total time are more than twice the standard deviation apart. These results are NOT repable. Percentage of the requests served within a certain time (ms) 50% 3 66% 3 75% 3 80% 3 90% 3 95% 3 98% 3 99% 3 100% 3 (longest request)
10 Concurrent Users Each Doing 10 Page Hits
这一测试为10个不同用户的100个页数,每个用户使用的是10个连续页数。
$ ab -r -n 10 -c 10 -k -H "Accept-Encoding: gzip, deflate" http://127.0.0.1:8000/
Output
... Requests per second: 2225.68 [#/sec] (mean) Time per request: 4.493 [ms] (mean) Time per request: 0.449 [ms] (mean, across all concurrent requests) Transfer rate: 602.07 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 1 2 0.7 2 3 Processing: 0 2 1.0 2 3 Waiting: 0 1 1.0 2 3 Total: 4 4 0.3 4 4 WARNING: The median and mean for the waiting time are not within a normal deviation These results are probably not that repable. Percentage of the requests served within a certain time (ms) 50% 4 66% 4 75% 4 80% 4 90% 4 95% 4 98% 4 99% 4 100% 4 (longest request)
20 Concurrent Users Each Doing 20 Page Hits
这一测试为20个不同用户的400个页面负荷,每个用户都在使用20个连续页的负荷。
$ ab -r -n 20 -c 20 -k -H “Accept-Encoding: gzip, deflate” http://127.0.0.1:8000/
Output
... Requests per second: 1619.96 [#/sec] (mean) Time per request: 12.346 [ms] (mean) Time per request: 0.617 [ms] (mean, across all concurrent requests) Transfer rate: 438.21 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 2 6 2.3 6 10 Processing: 1 5 2.9 5 10 Waiting: 0 5 2.9 5 9 Total: 10 11 0.6 11 12 Percentage of the requests served within a certain time (ms) 50% 11 66% 11 75% 12 80% 12 90% 12 95% 12 98% 12 99% 12 100% 12 (longest request)
30 Concurrent Users Each Doing 30 Page Hits
这一测试为30个不同用户的900个页面负荷,每个用户使用的是30个连续页数。
$ ab -r -n 30 -c 30 -k -H "Accept-Encoding: gzip, deflate" http://127.0.0.1:8000/
Output
... Requests per second: 2283.45 [#/sec] (mean) Time per request: 13.138 [ms] (mean) Time per request: 0.438 [ms] (mean, across all concurrent requests) Transfer rate: 617.69 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 2 6 2.7 6 11 Processing: 1 6 3.1 6 11 Waiting: 0 5 3.2 5 10 Total: 11 12 0.5 12 13 Percentage of the requests served within a certain time (ms) 50% 12 66% 12 75% 12 80% 12 90% 13 95% 13 98% 13 99% 13 100% 13 (longest request)
我们现在学会如何逐步增加网站的负荷并测试其业绩。
Apache Bench - Comparison of Outputs
在本章中,我们将对产出与无国旗进行比较。 让我们看看,如何使用适当的旗帜来提高你网络应用的绩效。 在此之前,我们需要理解,如果你的申请简单,那么你可能不会注意到这种区别。 就像我们简单的应用一样,有旗帜和无旗帜。 然后,我们将以
Testing our Apppcation without Flags
在本节中,我们将理解如何在没有旗帜的情况下检验我们的申请。
$ ab -n 100 -c 10 http://127.0.0.1:8000/
Output
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient).....done Server Software: Rocket Server Hostname: 127.0.0.1 Server Port: 8000 Document Path: / Document Length: Variable Concurrency Level: 10 Time taken for tests: 0.244 seconds Complete requests: 100 Failed requests: 0 Non-2xx responses: 100 Keep-Apve requests: 0 Total transferred: 27700 bytes HTML transferred: 6600 bytes Requests per second: 2208.77 [#/sec] (mean) Time per request: 4.527 [ms] (mean) Time per request: 0.453 [ms] (mean, across all concurrent requests) Transfer rate: 597.49 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 1 2 0.7 2 3 Processing: 0 2 0.7 2 4 Waiting: 0 2 1.0 2 3 Total: 4 4 0.3 4 5 Percentage of the requests served within a certain time (ms) 50% 4 66% 4 75% 5 80% 5 90% 5 95% 5 98% 5 99% 5 100% 5 (longest request)
Testing our Apppcation with Flags
在这一节中,我们将理解如何用旗子检验我们的申请。
$ ab -l -r -n 100 -c 10 -k -H "Accept-Encoding: gzip, deflate" http://127.0.0.1:8000/
Output
... Requests per second: 2277.07 [#/sec] (mean) Time per request: 4.392 [ms] (mean) Time per request: 0.439 [ms] (mean, across all concurrent requests) Transfer rate: 615.97 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 1 2 0.7 2 3 Processing: 0 2 0.7 2 4 Waiting: 0 2 1.0 2 3 Total: 4 4 0.2 4 5 Percentage of the requests served within a certain time (ms) 50% 4 66% 4 75% 4 80% 4 90% 5 95% 5 98% 5 99% 5 100% 5 (longest request)
我们可以简单地指出,产出统计之间没有多大差别。
Testing Apache Organisation Website without Flags
我们现在看看如何在没有旗帜的情况下测试阿帕奇组织网站。
$ ab -n 100 -c 10 http://www.apache.org/
Output
This is ApacheBench, Version 2.3 <$Revision: 1604373 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking www.apache.org (be patient).....done Server Software: Apache/2.4.7 Server Hostname: www.apache.org Server Port: 80 Document Path: / Document Length: 58433 bytes Concurrency Level: 10 Time taken for tests: 1.498 seconds Complete requests: 100 Failed requests: 0 Total transferred: 5877500 bytes HTML transferred: 5843300 bytes Requests per second: 66.74 [#/sec] (mean) Time per request: 149.840 [ms] (mean) Time per request: 14.984 [ms] (mean, across all concurrent requests) Transfer rate: 3830.58 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 12 110 295.2 12 1012 Processing: 37 38 0.5 38 39 Waiting: 12 13 0.3 13 15 Total: 49 147 295.4 50 1051 Percentage of the requests served within a certain time (ms) 50% 50 66% 50 75% 50 80% 50 90% 816 95% 1050 98% 1051 99% 1051 100% 1051 (longest request)
Testing Apache Organisation Website with Flags
我们现在用旗帜测试阿帕奇组织网站。
$ ab -l -r -n 100 -c 10 -k -H "Accept-Encoding: gzip, deflate" http://www.apache.org/
Output
... Document Length: Variable Concurrency Level: 10 Time taken for tests: 0.357 seconds Complete requests: 100 Failed requests: 0 Keep-Apve requests: 100 Total transferred: 1358510 bytes HTML transferred: 1317700 bytes Requests per second: 280.28 [#/sec] (mean) Time per request: 35.678 [ms] (mean) Time per request: 3.568 [ms] (mean, across all concurrent requests) Transfer rate: 3718.41 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 3.7 0 12 Processing: 14 17 21.3 15 227 Waiting: 14 17 21.3 14 227 Total: 14 18 21.5 15 227 Percentage of the requests served within a certain time (ms) 50% 15 66% 15 75% 15 80% 15 90% 27 95% 28 98% 29 99% 227 100% 227 (longest request)
你可以简单地指出,通过使用旗帜,每二次请求是如何增加的。 在本案中,这尤其因为使用了-H“Accept-Encoding: gzip,因为这一旗帜指阿帕奇服务器在gzipped格式中服务。
Considering the Apache Bench Results
在讨论阿帕奇科小组的成果时,需要考虑几个要点。 这将有助于我们制定总体战略,消除我们应用中的瓶颈,并改进其业绩。
我们需要第二批。 这使我们想到我们网络服务器的建立工作做得如何;数量越大,业绩越好。 然后是《联系时报》和所接到要求的百分比。 您可能不得不 t击你的网络服务器的环境,以改变这些衡量标准,使其达到预期的业绩。
如果阿帕奇的或使用的网络服务器错误记录或(一般)记录有错误,则进行检查。 随着你增加负荷,事情将开始cho:记忆问题将开始出现。 如果不写上一致的文字,许多文字就开始坠毁。
你们需要找到贵国网络服务器坠毁和(或)停机上的关键一致价值是什么? 通常,这种情况应在相当高的一致程度发生。 如果这种价值很低,那是错的,你需要调整这些环境,降低/提高。
Conclusion
在这一理论中,我们学会了阿帕奇科法官如何用来装载任何网站或网络应用的测试。 阿帕奇科法官可以成为一个非常宝贵的工具,用来确定如何改进你的网络应用服务器的设置,以减少瓶颈,提高业绩。 既然你熟悉阿帕奇科法官的基本使用情况,你可以首先制定新的测试计划,以衡量你在不同情况下的运用情况。
Advertisements