天天看點

linux 壓力測試指令 abApacheBench安裝使用的方法:應用

ApacheBench

ab是apacheBench的縮寫,是一個單線程指令,是Apache伺服器自帶的一個web壓力測試工具,最初是用于測試Apache HTTP Server。使用時,ab指令會建立并發通路線程,模拟多個通路者同時對某一個URL位址進行通路。

安裝

yum -y install httpd-tools
           

使用的方法:

ab [option] [http://]host[:port]/path
           

其中[option]是ab指令提供的可選參數,常用的參數:

-n 指定壓力測試總共通路頁面的次數,預設是1

-c 用于一次産生請求的并發數,預設是1

應用

測試IP位址為192.168.153.185上的web服務

[[email protected] ~]# ab -c 200 -n 10000 http://192.168.153.185/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.153.185 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.18.0
Server Hostname:        192.168.153.185
Server Port:            80

Document Path:          /
Document Length:        612 bytes

Concurrency Level:      200
Time taken for tests:   3.133 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      8450000 bytes
HTML transferred:       6120000 bytes
Requests per second:    3191.77 [#/sec] (mean)
Time per request:       62.661 [ms] (mean)
Time per request:       0.313 [ms] (mean, across all concurrent requests)
Transfer rate:          2633.83 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   21  82.3     12    1032
Processing:     4   31  35.7     25     858
Waiting:        4   30  35.6     24     858
Total:         10   52  91.2     40    1236

Percentage of the requests served within a certain time (ms)
  50%     40
  66%     46
  75%     51
  80%     54
  90%     66
  95%     91
  98%    212
  99%    264
 100%   1236 (longest request)
[[email protected] ~]#