page counter next up previous contents
Next: 防止 DoS Up: Apache 2.2 HTTP Server Previous: 安全機制   Contents   DYWANG_HOME

AB test

  1. 在 Apache 套件工具有個叫 ab(ApacheBench) 的程式,專門用在做壓力測試。安裝套件 httpd-tools。
    [root@e517nat ~]# yum install httpd-tools
    
  2. moodle.cyut.edu.tw 本機直接進行壓力測試,同時 1000 個連線做 20 次,測試結果前 50% 完成連線需要 1722ms, 100% 完成連線需要 2141ms。
    [root@moodle ~]#  ab -n 1000 -c 20 http://moodle.cyut.edu.tw/index.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 moodle.cyut.edu.tw (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.15
    Server Hostname:        moodle.cyut.edu.tw
    Server Port:            80
    
    Document Path:          /index.php
    Document Length:        38781 bytes
    
    Concurrency Level:      20
    Time taken for tests:   86.830 seconds
    Complete requests:      1000
    Failed requests:        0
    Write errors:           0
    Total transferred:      39357000 bytes
    HTML transferred:       38781000 bytes
    Requests per second:    11.52 [#/sec] (mean)
    Time per request:       1736.599 [ms] (mean)
    Time per request:       86.830 [ms] (mean, across all concurrent requests)
    Transfer rate:          442.64 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    1   5.5      0      62
    Processing:   896 1730 109.4   1722    2141
    Waiting:      775 1236  77.5   1230    1615
    Total:        897 1730 110.5   1722    2141
    
    Percentage of the requests served within a certain time (ms)
      50%   1722
      66%   1758
      75%   1782
      80%   1800
      90%   1855
      95%   1905
      98%   1982
      99%   2025
     100%   2141 (longest request)
    
  3. 從外部主機 dyw219 進行壓力測試,同時 1000 個連線做 20 次,只能同時 229 個連線,無法完成同時 1000 個連線的測試。經查詢路由中為防止 DoS 攻擊,限制同一 ip 同時間最多只能 200 sessions。
    [root@dyw219 nat]# ab -n 1000 -c 20 http://moodle.cyut.edu.tw/index.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 moodle.cyut.edu.tw (be patient)
    Completed 100 requests
    Completed 200 requests
    apr_poll: The timeout specified has expired (70007)
    Total of 229 requests completed
    
  4. 經放行主機 e517nat 後進行壓力測試,同時 1000 個連線做 20 次,測試結果前 50% 完成連線需要 1742ms, 100% 完成連線需要 2182ms。
    [root@e517nat ~]# ab -n 1000 -c 20 http://moodle.cyut.edu.tw/index.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 moodle.cyut.edu.tw (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.15
    Server Hostname:        moodle.cyut.edu.tw
    Server Port:            80
    
    Document Path:          /index.php
    Document Length:        38781 bytes
    
    Concurrency Level:      20
    Time taken for tests:   87.383 seconds
    Complete requests:      1000
    Failed requests:        0
    Write errors:           0
    Total transferred:      39357000 bytes
    HTML transferred:       38781000 bytes
    Requests per second:    11.44 [#/sec] (mean)
    Time per request:       1747.652 [ms] (mean)
    Time per request:       87.383 [ms] (mean, across all concurrent requests)
    Transfer rate:          439.84 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    1   1.0      1      30
    Processing:   921 1740 145.2   1741    2181
    Waiting:      371 1248 105.8   1249    1588
    Total:        922 1740 145.2   1742    2182
    
    Percentage of the requests served within a certain time (ms)
      50%   1742
      66%   1800
      75%   1833
      80%   1853
      90%   1913
      95%   1965
      98%   2024
      99%   2071
     100%   2182 (longest request)
    



De-Yu Wang 2020-05-19