apache bench的使用

1 输入参数

运行参数

简写

名称

意义

-n

requests

Number of requests to perform

-c

concurrency

Number of multiple requests to make(最大为1024)

-t

timelimit

Seconds to max. wait for responses

-p

postfile

File containing data to POST

-T

content-type

Content-type header for POSTing

-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

-h

 

Display usage information (this message)

     
     

举例:ab –n 1000 –c 10 http://localhost:8080/test/index.jsp

表示向本机8080端口发送1000个请求,并发数为10

2 输出及解析

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 localhost (be patient).....done

Server Software:        Apache-Coyote/1.1

Server Hostname:        localhost

Server Port:            8080

Document Path:          /test/index.jsp

Document Length:        163 bytes

Concurrency Level:      10

/*整个测试持续的时间*/

Time taken for tests:   1.344 seconds

/*完成的请求数量*/

Complete requests:      1000

/*失败的请求数量*/

Failed requests:        0

Write errors:           0

/*整个场景中的网络传输量*/

Total transferred:      388000bytes

/*整个场景中的HTML内容传输量*/

HTML transferred:       163000 bytes

/*每秒事务数,后面括号中的 mean 表示这是一个平均值*/

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

/* 平均事务响应时间,后面括号中的 mean 表示这是一个平均值*/

Time per request:       13.438 [ms] (mean)

/*平均事物响应时间/并发数 */

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

/*平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题*/

Transfer rate:          281.98 [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%   16

  66%   16

  75%   16

  80%   16

  90%   16

  95%   31

  98%   94

  99%   313

100%   328 (longest request)

计划、执行、每天高效的活着学着
原文地址:https://www.cnblogs.com/huxiaoyun90/p/3118849.html