AB压力测试工具

1.安装AB工具:

yum install httpd-tools

2.测试:

ab -n 100 -c 10 http://localhost.com/

其中-n表示请求数,-c表示并发数

3.测试结果

[root@vijay01 ~]# ab -c 10 -n 1000 http://192.168.2.11/ab.html
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 192.168.2.11 (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:        nginx/1.0.15
Server Hostname:        192.168.2.11
Server Port:            80

Document Path:          /ab.html
Document Length:        3698 bytes

Concurrency Level:      10
Time taken for tests:   0.105 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      3910000 bytes
HTML transferred:       3698000 bytes
Requests per second:    9515.20 [#/sec] (mean)
Time per request:       1.051 [ms] (mean)
Time per request:       0.105 [ms] (mean, across all concurrent requests)
Transfer rate:          36332.46 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       2
Processing:     0    1   0.5      1       3
Waiting:        0    1   0.4      1       2
Total:          0    1   0.5      1       5

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%      2
  95%      2
  98%      2
  99%      3
 100%      5 (longest request)

--------------------------------------------------------------------------------------------------------------------

Server Software:        nginx/1.0.15
Server Hostname:        192.168.2.11
Server Port:            80
  • 这段展示的是web服务器的信息,可以看到服务器采用的是nginx,域名是wan.bigertech.com,端口是80
Document Path:          /ab.html
Document Length:        3698 bytes
  • 这段是关于请求的文档的相关信息,所在位置“/”,文档的大小为338436 bytes(此为http响应的正文长度)

------------------------------------------------------------------------------------------------------------------

Concurrency Level:      10
Time taken for tests:   0.105 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      3910000 bytes
HTML transferred:       3698000 bytes
Requests per second:    9515.20 [#/sec] (mean)
Time per request:       1.051 [ms] (mean)
Time per request:       0.105 [ms] (mean, across all concurrent requests)
Transfer rate:          36332.46 [Kbytes/sec] received
  • 这段展示了压力测试的几个重要指标

  Concurrency Level: 100           --并发请求数
  Time taken for tests: 50.872 seconds   --整个测试持续的时间
  Complete requests: 1000          --完成的请求数
  Failed requests: 0                 --失败的请求数

  Total transferred: 13701482 bytes      --整个场景中的网络传输量
  HTML transferred: 13197000 bytes     --整个场景中的HTML内容传输量

Requests per second: 19.66 [#/sec] (mean)     --吞吐率,大家最关心的指标之一,相当于 LR 中的每秒事务数,后面括号中的 mean 表示这是一个平均值
Time per request: 5087.180 [ms] (mean)          --用户平均请求等待时间,大家最关心的指标之二,相当于 LR 中的平均事务响应时间,后面括号中的 mean 表示这是一个平均值
Time per request: 50.872 [ms] (mean, across all concurrent requests)    --服务器平均请求处理时间,大家最关心的指标之三

Transfer rate: 263.02 [Kbytes/sec] received             --平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题

-----------------------------------------------------------------------------------------------------

Connection Times (ms) min  mean[+/-sd] median   max
Connect:               0    0   0.2      0       2
Processing:         0    1   0.5      1       3
Waiting:            0    1   0.4      1       2
Total:              0    1   0.5      1       5
  • 这段表示网络上消耗的时间的分解

------------------------------------------------------------------------------------------------------

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%      2
  95%      2
  98%      2
  99%      3
 100%      5 (longest request)

  

  • 这段是每个请求处理时间的分布情况,50%的处理时间在4930ms内,66%的处理时间在5008ms内...,重要的是看90%的处理时间。



 

 

原文地址:https://www.cnblogs.com/vijayfly/p/5351887.html