English 中文(简体)
Preparation for Testing Dynamic Pages
  • 时间:2024-03-25 07:37:25

Preparation for Testing Dynamic Pages


Previous Page Next Page  

在本章中,我们将理解测试动态页面所需的准备工作。 服务器边动态网页是网页,其施工由应用服务器处理服务器边文字控制。 沥青板只能对服务器边动态网页进行负荷测试。

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

我们将迅速安装另一个电灯光网。 你们可以更多地了解如何在上使用。 Web2py Framework Overview

一般来说,在乌班图和德比亚服务器上安装了灰尘。 因此,已经满足了成功运行网络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,如下图所示。

Session Cookie from web2py

注:在打字之前, co的数值为y接受 co。 现在,终端站将与以下图像相类似:终端网站!

Website on the Terminal

在获得了厨师的价值后,我们现在将进行 a测试。 为此,我们必须打开第三个终点站(见下图)——

Cookie Value

现在,让我们在第三个终点站使用——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使用Rocket 网络服务器。 我们还注意到,除了先前讨论的产出标题外,我们还正在获得“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。 让我们从中理解这一点,而“b是相当解释性的。

-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分钟。

    确保同时连接的数量低于阿帕帕奇工人校对。

    如果阿帕奇或皮星坠毁,在进行另一场测试之前,你应更换服务器。

Advertisements