压力测试工具Apache Bench

1:吞吐率(Requests per second)

服务器并发处理能力的量化描述,单位是reqs/s,指的是某个并发用户数下单位时间内处理的请求数。某个并发用户数下单位时间内能处理的最大请求数,称之为最大吞吐率。

记住:吞吐率是基于并发用户数的。这句话代表了两个含义,1:吞吐率和并发用户数相关;2:不同的并发用户数下,吞吐率一般是不同的。

计算公式:总请求数 / 处理完成这些请求数所花费的时间,即

Request per second = Complete requests / Time taken for tests

2:并发连接数(The number of concurrent connections)

并发连接数指的是某个时刻服务器所接受的请求数目,简单的讲,就是一个会话。

3:并发用户数(The number of concurrent users,Concurrency Level)

要注意区分这个概念和并发连接数之间的区别,一个用户可能同时会产生多个会话,也即连接数。在HTTP/1.1下,IE7支持两个并发连接,IE8支持6个并发连接,FireFox3支持4个并发连接,所以相应的,我们的并发用户数就得除以这个基数。

4:用户平均请求等待时间(Time per request)

计算公式:处理完成所有请求数所花费的时间/ (总请求数 / 并发用户数),即

Time per request = Time taken for tests /( Complete requests / Concurrency Level)

5:服务器平均请求等待时间(Time per request: across all concurrent requests)

计算公式:处理完成所有请求数所花费的时间 / 总请求数,即

Time taken for / testsComplete requests

可以看到,它是吞吐率的倒数。

同时,它也=用户平均请求等待时间/并发用户数,即

Time per request / Concurrency Level

 

官网下载地址:https://www.apachelounge.com/download/

压力测试工具Apache Bench

 下载后解压,用cmd进入当前的项目解压目录:

然后进入shell命令的执行界面(进入到bin目录下):

压力测试工具Apache Bench

 

测试命令:

./ab -n 100 -c 10 http://localhost:8085/linewell/test1/pass/testApacheBench.do

输出:

This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
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).....done


Server Software:
Server Hostname:        localhost
Server Port:            8085

Document Path:          /linewell/test1/pass/testApacheBench.do
Document Length:        0 bytes

Concurrency Level:      10
Time taken for tests:   0.077 seconds
Complete requests:      100
Failed requests:        0
Non-2xx responses:      100
Total transferred:      9200 bytes
HTML transferred:       0 bytes
Requests per second:    1299.09 [#/sec] (mean)
Time per request:       7.698 [ms] (mean)
Time per request:       0.770 [ms] (mean, across all concurrent requests)
Transfer rate:          116.72 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       1
Processing:     1    5   3.4      5      27
Waiting:        1    4   3.1      4      26
Total:          2    5   3.4      5      27

Percentage of the requests served within a certain time (ms)
  50%      5
  66%      6
  75%      7
  80%      7
  90%      9
  95%     11
  98%     11
  99%     27
 100%     27 (longest request)

 

输出结果解析:

压力测试工具Apache Bench

 压力测试工具Apache Bench

压力测试工具Apache Bench

压力测试工具Apache Bench

压力测试工具Apache Bench

 压力测试工具Apache Bench

 

上一篇:STM32_LCD_ASCII码函数(显示)


下一篇:JSON数据和Java对象的相互转换