服务器并发能力测试 Apache Beach - Tech - JavaEye论坛

1.打开windows cmd(以下数据兼为windows xp平台运行数据)

2.Cd Apache bin目录。

3.运行ab.exe  ( ApacheBench command line utility)

 

Java代码 复制代码
  1. Usage: ab [options] [http://]hostname[:port]/path   
  2. Options are:   
  3.     -n requests     Number of requests to perform   
  4.     -c concurrency  Number of multiple requests to make   
  5.     -t timelimit    Seconds to max. wait for responses   
  6.     -b windowsize   Size of TCP send/receive buffer, in bytes   
  7.     -p postfile     File containing data to POST. Remember also to set -T   
  8.     -T content-type Content-type header for POSTing, eg.   
  9.                     'application/x-www-form-urlencoded'  
  10.                     Default is 'text/plain'  
  11.     -v verbosity    How much troubleshooting info to print   
  12.     -w              Print out results in HTML tables   
  13.     -i              Use HEAD instead of GET   
  14.     -x attributes   String to insert as table attributes   
  15.     -y attributes   String to insert as tr attributes   
  16.     -z attributes   String to insert as td or th attributes   
  17.     -C attribute    Add cookie, eg. 'Apache=1234. (repeatable)   
  18.     -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'  
  19.                     Inserted after all normal header lines. (repeatable)   
  20.     -A attribute    Add Basic WWW Authentication, the attributes   
  21.                     are a colon separated username and password.   
  22.     -P attribute    Add Basic Proxy Authentication, the attributes   
  23.                     are a colon separated username and password.   
  24.     -X proxy:port   Proxyserver and port number to use   
  25.     -V              Print version number and exit   
  26.     -k              Use HTTP KeepAlive feature   
  27.     -d              Do not show percentiles served table.   
  28.     -S              Do not show confidence estimators and warnings.   
  29.     -g filename     Output collected data to gnuplot format file.   
  30.     -e filename     Output CSV file with percentages served   
  31.     -r              Don't exit on socket receive errors.   
  32.     -h              Display usage information (this message)  
Usage: ab [options] [http://]hostname[:port]/path
Options are:
    -n requests     Number of requests to perform
    -c concurrency  Number of multiple requests to make
    -t timelimit    Seconds to max. wait for responses
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -p postfile     File containing data to POST. Remember also to set -T
    -T content-type Content-type header for POSTing, eg.
                    'application/x-www-form-urlencoded'
                    Default is 'text/plain'
    -v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of 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)
    -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.
    -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
    -r              Don't exit on socket receive errors.
    -h              Display usage information (this message)

 

 

D:/wamp/bin/apache/Apache2.2.11/bin>

4.输入测试数据  -n1000 -c10 http://localhost/oop5.php

-n1000 表示总请求数为1000

-c10 表示并发用户数为10

http://localhost/oop5.php 表示请求的超链接地址

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 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 <$Revision: 655654 $>

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)




引文来源  服务器并发能力测试 Apache Beach - Tech - JavaEye论坛

展开阅读全文

没有更多推荐了,返回首页