首页 / 享图 / 视频中心 / 经典小游戏


    + 相关信息

  • 关键字:
    APACHE自带的测试工具AB(apache benchmark).在APACHE的bin目录。格式: ./ab [options] [http://]hostname[:port]/path参数:-n reque ...apache benchmark 调试详解
  • 发表: 快乐小号
  • 时间: 2010-07-13 15:15:31

    + 访问历史

  • 仅有游客查阅
  •  apache benchmark 调试详解     同步 主题
APACHE自带的测试工具AB(apache benchmark).在APACHE的bin目录。
格式: ./ab [options] [http://]hostname[:port]/path
参数:
-n requests Number of requests to perform
//在测试会话中所执行的请求个数。默认时,仅执行一个请求 
-c concurrency Number of multiple requests to make
//一次产生的请求个数。默认是一次一个。 
-t timelimit Seconds to max. wait for responses
//测试所进行的最大秒数。其内部隐含值是-n 50000。它可以使对服务器的测试限制在一个固定的总时间以内。默认时,没有时间限制。
-p postfile File containing data to POST
//包含了需要POST的数据的文件. 
-T content-type Content-type header for POSTing
//POST数据所使用的Content-type头信息。 
-v verbosity How much troubleshooting info to print
//设置显示信息的详细程度 - 4或更大值会显示头信息, 3或更大值可以显示响应代码(404, 200等), 2或更大值可以显示警告和其他信息。 -V 显示版本号并退出。
-w Print out results in HTML tables
//以HTML表的格式输出结果。默认时,它是白色背景的两列宽度的一张表。
-i Use HEAD instead of GET
// 执行HEAD请求,而不是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 Add cookie, eg. 'Apache=1234. (repeatable)
//-C cookie-name=value 对请求附加一个Cookie:行。 其典型形式是name=value的一个参数对。此参数可以重复。 
-H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip' Inserted after all normal header lines. (repeatable)
-A attribute Add Basic WWW Authentication, the attributes
are a colon separated username and password.
-P attribute Add Basic Proxy Authentication, the attributes
are a colon separated username and password.
//-P proxy-auth-username:password 对一个中转代理提供BASIC认证信任。用户名和密码由一个:隔开,并以base64编码形式发送。无论服务器是否需要(即, 是否发送了401认证需求代码),此字符串都会被发送。 
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-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)
//-attributes 设置 属性的字符串. 缺陷程序中有各种静态声明的固定长度的缓冲区。另外,对命令行参数、服务器的响应头和其他外部输入的解析也很简单,这可能会有不良后果。它没有完整地实现 HTTP/1.x; 仅接受某些'预想'的响应格式。 strstr(3)的频繁使用可能会带来性能问题,即, 你可能是在测试ab而不是服务器的性能。

参数很多,一般我们用 -c 和 -n 参数就可以了. 例如:

./ab -c 1000 -n 1000 http://127.0.0.1/index.php 

这个表示同时处理1000个请求并运行1000次index.php文件.
#/usr/local/xiaobai/apache2054/bin/ab -c 1000 -n 1000 http://127.0.0.1/index.html.zh-cn.gb2312 
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ 
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ 

Benchmarking 127.0.0.1 (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
Finished 1000 requests

Server Software: Apache/2.0.54
//平台apache 版本2.0.54
Server Hostname: 127.0.0.1
//服务器主机名
Server Port: 80
//服务器端口 

Document Path: /index.html.zh-cn.gb2312
//测试的页面文档 
Document Length: 1018 bytes
//文档大小 

Concurrency Level: 1000
//并发数
Time taken for tests: 8.188731 seconds
//整个测试持续的时间 
Complete requests: 1000
//完成的请求数量 
Failed requests: 0
//失败的请求数量 
Write errors: 0

Total transferred: 1361581 bytes
//整个场景中的网络传输量 
HTML transferred: 1055666 bytes
//整个场景中的HTML内容传输量
Requests per second: 122.12 [#/sec] (mean)
//大家最关心的指标之一,相当于 LR 中的 每秒事务数 ,后面括号中的 mean 表示这是一个平均值 
Time per request: 8188.731 [ms] (mean)
//大家最关心的指标之二,相当于 LR 中的 平均事务响应时间 ,后面括号中的 mean 表示这是一个平均值 
Time per request: 8.189 [ms] (mean, across all concurrent requests)
//每个请求实际运行时间的平均值 
Transfer rate: 162.30 [Kbytes/sec] received
//平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题 

Connection Times (ms)
min mean[+/-sd] median max
Connect: 4 646 1078.7 89 3291
Processing: 165 992 493.1 938 4712
Waiting: 118 934 480.6 882 4554
Total: 813 1638 1338.9 1093 7785
//网络上消耗的时间的分解,各项数据的具体算法还不是很清楚 

Percentage of the requests served within a certain time (ms)
50% 1093
66% 1247
75% 1373
80% 1493
90% 4061
95% 4398
98% 5608
99% 7368
100% 7785 (longest request)
//整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中50%的用户响应时间小于1093 毫秒,60% 的用户响应时间小于1247 毫秒,最大的响应时间小于7785 毫秒 

由于对于并发请求,cpu实际上并不是同时处理的,而是按照每个请求获得的时间片逐个轮转处理的,所以基本上第一个Time per request时间约等于第二个Time per request时间乘以并发请求数
分享到QQ空间 填写您的邮件地址,订阅我们的精彩内容:
2010-07-13 15:15:31 / [编辑] / [删除]
  •  [快乐小号] 于 2010-07-13 15:19:38管理

    D:wampbinapacheApache2.2.11bin>
    4.输入测试数据 -n1000 -c10 http://localhost/oop5.php
    -n1000 表示总请求数为1000
    -c10 表示并发用户数为10
    http://localhost/oop5.php 表示请求的超链接地址
    This is ApacheBench, Version 2.3

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

    Licensed to The Apache Software Foundation, http://www.apache.org/



    Benchmarking localhost (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.2.11 被测试的web服务器名称,它来自HTTP响应数据的头信息
    Server Hostname: localhost 请求URL 中主机部分名称,它来自HTTP请求数据的头信息
    Server Port: 80 被测试web服务器的监听端口


    Document Path: /oop5.php 表示请求URL中的根绝对路径,它来自HTTP请求数据的头信息
    Document Length: 222 bytes 表示HTTP响应数据的正文长度


    Concurrency Level: 10 并发数
    Time taken for tests: 5.125 seconds 表示所有请求被处理完成所需要的总时间
    Complete requests: 1000 完成的实际请求数
    Failed requests: 0 失败的请求数
    Write errors: 0 请求写入失败的次数

    Total transferred: 409000 bytes 表示所有请求的响应数据长度总和(header length + context length)
    HTML transferred: 222000 bytes 总的响应数据中正文长度(context length)
    Requests per second: 195.12 [#/sec] (mean) 吞吐率= Complete requests / Time taken for tests

    Time per request: 51.250 [ms] (mean) 用户平均请求等待时间
    Time per request: 5.125 [ms] (mean, across all concurrent requests) 服务器平均处理请求时间
    Transfer rate: 77.93 [Kbytes/sec] received 表示请求在单位时间内从服务器获取的数据长度


    Connection Times (ms)

    min mean[+/-sd] median max

    Connect: 0 0 2.1 0 16

    Processing: 16 51 7.5 47 78

    Waiting: 16 51 7.4 47 78

    Total: 16 51 7.6 47 78



    Percentage of the requests served within a certain time (ms) 每个请求处理时间分布情况
    50% 47

    66% 47

    75% 63

    80% 63

    90% 63

    95% 63

    98% 63

    99% 63

    100% 78 (longest request)

    分析以上关键数据

    吞吐率Requests per second : 195.12 [#/sec] (mean)
    请求等待时间Time per request :51.250 [ms] (mean)
    请求处理时间 Time per request :5.125 [ms] (mean, across all concurrent requests)



    5. 继续测试 -n1000 -c100 http://localhost/oop5.php

    并发数设置为100,运行结果为
    Server Software: Apache/2.2.11

    Server Hostname: localhost

    Server Port: 80



    Document Path: /oop5.php

    Document Length: 222 bytes



    Concurrency Level: 100

    Time taken for tests: 5.672 seconds

    Complete requests: 1000

    Failed requests: 0

    Write errors: 0

    Total transferred: 409000 bytes

    HTML transferred: 222000 bytes

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

    Time per request: 567.188 [ms] (mean)

    Time per request: 5.672 [ms] (mean, across all concurrent requests)
    Transfer rate: 70.42 [Kbytes/sec] received



    Connection Times (ms)

    min mean[+/-sd] median max

    Connect: 0 0 1.9 0 16

    Processing: 63 551 88.8 547 859

    Waiting: 63 551 88.7 547 859

    Total: 63 552 88.8 547 859



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

    50% 547

    66% 563

    75% 563

    80% 578

    90% 609

    95% 719

    98% 797

    99% 828

    100% 859 (longest request)





    分析以上关键数据

    吞吐率Requests per second : 176.31 [#/sec] (mean)
    请求等待时间Time per request :567.188 [ms] (mean)
    请求处理时间 Time per request :5.672 [ms] (mean, across all concurrent requests)



    6.继续测试 -n1000 –c200 http://localhost/oop5.php



    Server Software: Apache/2.2.11

    Server Hostname: localhost

    Server Port: 80



    Document Path: /oop5.php

    Document Length: 222 bytes



    Concurrency Level: 200

    Time taken for tests: 6.047 seconds

    Complete requests: 1000

    Failed requests: 0

    Write errors: 0

    Total transferred: 409000 bytes

    HTML transferred: 222000 bytes

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

    Time per request: 1209.375 [ms] (mean)

    Time per request: 6.047 [ms] (mean, across all concurrent requests)
    Transfer rate: 66.05 [Kbytes/sec] received



    Connection Times (ms)

    min mean[+/-sd] median max

    Connect: 0 0 2.5 0 16

    Processing: 109 1124 219.8 1188 1438

    Waiting: 109 1124 219.7 1188 1438

    Total: 109 1124 219.8 1188 1438



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

    50% 1188

    66% 1234

    75% 1234

    80% 1234

    90% 1250

    95% 1297

    98% 1375

    99% 1406

    100% 1438 (longest request)



    7.继续测试 -n2000 –c200 http://localhost/oop5.php

    This is ApacheBench, Version 2.3

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

    Licensed to The Apache Software Foundation, http://www.apache.org/



    Benchmarking localhost (be patient)

    Completed 200 requests

    Completed 400 requests

    Completed 600 requests

    Completed 800 requests

    Completed 1000 requests

    Completed 1200 requests

    Completed 1400 requests

    Completed 1600 requests

    Completed 1800 requests

    Completed 2000 requests

    Finished 2000 requests





    Server Software: Apache/2.2.11

    Server Hostname: localhost

    Server Port: 80



    Document Path: /oop5.php

    Document Length: 222 bytes



    Concurrency Level: 200

    Time taken for tests: 11.750 seconds

    Complete requests: 2000

    Failed requests: 0

    Write errors: 0

    Total transferred: 818000 bytes

    HTML transferred: 444000 bytes

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

    Time per request: 1175.000 [ms] (mean)

    Time per request: 5.875 [ms] (mean, across all concurrent requests)
    Transfer rate: 67.99 [Kbytes/sec] received



    Connection Times (ms)

    min mean[+/-sd] median max

    Connect: 0 0 2.2 0 16

    Processing: 109 1134 155.8 1156 1469

    Waiting: 109 1134 155.8 1156 1469

    Total: 109 1134 155.8 1156 1469



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

    50% 1156

    66% 1172

    75% 1188

    80% 1203

    90% 1219

    95% 1234

    98% 1328

    99% 1406

    100% 1469 (longest request)





    8.继续测试 持久连接(Keep-alive)
    未启用持久连接模式 -n1000 –c100 http://www.zjut.edu.cn/



    Server Software: Apache-Coyote/1.1

    Server Hostname: www.zjut.edu.cn

    Server Port: 80



    Document Path: /

    Document Length: 0 bytes



    Concurrency Level: 100

    Time taken for tests: 2.094 seconds

    Complete requests: 1000

    Failed requests: 0

    Write errors: 0

    Non-2xx responses: 1000

    Total transferred: 294000 bytes

    HTML transferred: 0 bytes

    Requests per second: 477.61 [#/sec] (mean)
    Time per request: 209.375 [ms] (mean)

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

    Transfer rate: 137.13 [Kbytes/sec] received



    Connection Times (ms)

    min mean[+/-sd] median max

    Connect: 0 2 5.0 0 16

    Processing: 0 193 49.9 203 266

    Waiting: 0 109 63.2 109 250

    Total: 0 195 50.2 203 266



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

    50% 203

    66% 219

    75% 219

    80% 234

    90% 250

    95% 250

    98% 250

    99% 250

    100% 266 (longest request)



    启用持久连接 ab -n1000 -c100 -k http://www.zjut.edu.cn/

    Server Software: Apache-Coyote/1.1

    Server Hostname: www.zjut.edu.cn

    Server Port: 80



    Document Path: /

    Document Length: 0 bytes



    Concurrency Level: 100

    Time taken for tests: 1.234 seconds

    Complete requests: 1000

    Failed requests: 0

    Write errors: 0

    Non-2xx responses: 1006

    Keep-Alive requests: 546
    Total transferred: 298494 bytes

    HTML transferred: 0 bytes

    Requests per second: 810.13 [#/sec] (mean)
    Time per request: 123.438 [ms] (mean)

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

    Transfer rate: 236.15 [Kbytes/sec] received



    Connection Times (ms)

    min mean[+/-sd] median max

    Connect: 0 1 3.6 0 16

    Processing: 0 106 27.5 94 188

    Waiting: 0 85 37.4 94 188

    Total: 0 107 27.6 94 188



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

    50% 94

    66% 109

    75% 125

    80% 125

    90% 156

    95% 156

    98% 156

    99% 172

    100% 188 (longest request)

无分页数据-

 回复