NGINX壓力測試

卡子火發表於2017-12-05

 

1    硬體配置    3

1.1    型號    3

1.2    CPU    3

1.3    記憶體    3

2    軟體環境    3

2.1    作業系統    3

2.2    服務版本    3

2.3    測試軟體    3

3    併發測試    3

3.1    1000併發    4

3.2    2000併發    5

3.3    3000併發    6

4    測試總結    8

4.1    資料彙總    8

4.2    資料分析    8

 

  1. 硬體配置

  1. 型號

    # dmidecode | grep “Product Name”

    Product Name: VMware Virtual Platform

    Product Name: 440BX Desktop Reference Platform

  2. CPU

    # cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq

    Intel(R) Xeon(R) CPU E5-2660 v4 @ 2.00GHz

  3. 記憶體

    # dmidecode|grep -P -A5 “Memorys+Device” | grep Size |grep -v Range | cat -n

    1        Size: 16384 MB

    2        Size: 4096 MB

    1. 軟體環境

  4. 作業系統

    # cat /etc/redhat-release

    CentOS Linux release 7.2.1511 (Core)

  5. 服務版本

    # /usr/local/openresty/nginx/sbin/nginx -v

    nginx version: openresty/1.11.2.4

  6. 測試軟體

    # ab -V

    This is ApacheBench, Version 2.3 <$Revision: 1430300 $>

    1. 併發測試

    說明:測試基於Linux系統。

  7. 1000併發

    測試1000併發,處理10000請求:

           # ab -c 1000 -n 10000 http://10.27.88.50/index.html

    Benchmarking 10.27.88.50 (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: openresty/1.11.2.4
    
    Server Hostname: 10.27.88.50
    
    Server Port: 80
    
     
    
    Document Path: /index.html
    
    Document Length: 612 bytes
    
     
    
    Concurrency Level: 1000
    
    Time taken for tests: 0.874 seconds
    
    Complete requests: 10000
    
    Failed requests: 0
    
    Write errors: 0
    
    Total transferred: 8510000 bytes
    
    HTML transferred: 6120000 bytes
    
    Requests per second: 11437.38 [#/sec] (mean)
    
    Time per request: 87.433 [ms] (mean)
    
    Time per request: 0.087 [ms] (mean, across all concurrent requests)
    
    Transfer rate: 9505.09 [Kbytes/sec] received
    
     
    
    Connection Times (ms)
    
    min mean[+/-sd] median max
    
    Connect: 0 2 5.9 0 27
    
    Processing: 4 12 27.8 7 801
    
    Waiting: 0 11 27.7 7 801
    
    Total: 5 14 29.9 7 807
    
     
    
    Percentage of the requests served within a certain time (ms)
    
    50% 7
    
    66% 8
    
    75% 8
    
    80% 8
    
    90% 38
    
    95% 59
    
    98% 61
    
    99% 62
    
    100% 807 (longest request)

    View Code

  8. 2000併發

    測試2000併發,處理50000請求:

           # ab -c 2000 -n 50000 http://10.27.88.50/index.html

    Benchmarking 10.27.88.50 (be patient)
    
    Completed 5000 requests
    
    Completed 10000 requests
    
    Completed 15000 requests
    
    Completed 20000 requests
    
    Completed 25000 requests
    
    Completed 30000 requests
    
    Completed 35000 requests
    
    Completed 40000 requests
    
    Completed 45000 requests
    
    Completed 50000 requests
    
    Finished 50000 requests
    
     
    
     
    
    Server Software: openresty/1.11.2.4
    
    Server Hostname: 10.27.88.50
    
    Server Port: 80
    
     
    
    Document Path: /index.html
    
    Document Length: 612 bytes
    
     
    
    Concurrency Level: 2000
    
    Time taken for tests: 2.689 seconds
    
    Complete requests: 50000
    
    Failed requests: 1
    
    (Connect: 0, Receive: 0, Length: 1, Exceptions: 0)
    
    Write errors: 0
    
    Non-2xx responses: 1
    
    Total transferred: 42549516 bytes
    
    HTML transferred: 30599587 bytes
    
    Requests per second: 18593.35 [#/sec] (mean)
    
    Time per request: 107.565 [ms] (mean)
    
    Time per request: 0.054 [ms] (mean, across all concurrent requests)
    
    Transfer rate: 15451.92 [Kbytes/sec] received
    
     
    
    Connection Times (ms)
    
    min mean[+/-sd] median max
    
    Connect: 0 20 137.3 0 1004
    
    Processing: 1 18 121.7 4 1605
    
    Waiting: 0 18 121.7 4 1605
    
    Total: 2 38 236.7 5 2608
    
     
    
    Percentage of the requests served within a certain time (ms)
    
    50% 5
    
    66% 5
    
    75% 5
    
    80% 5
    
    90% 8
    
    95% 8
    
    98% 404
    
    99% 1406
    
    100% 2608 (longest request)

    View Code

  9. 3000併發

    測試3000併發,處理100000請求:

    # ab -c 3000 -n 100000 http://10.27.88.50/index.html

    Benchmarking 10.27.88.50 (be patient)
    
    Completed 10000 requests
    
    Completed 20000 requests
    
    Completed 30000 requests
    
    Completed 40000 requests
    
    Completed 50000 requests
    
    Completed 60000 requests
    
    Completed 70000 requests
    
    Completed 80000 requests
    
    Completed 90000 requests
    
    Completed 100000 requests
    
    Finished 100000 requests
    
     
    
     
    
    Server Software: openresty/1.11.2.4
    
    Server Hostname: 10.27.88.50
    
    Server Port: 80
    
     
    
    Document Path: /index.html
    
    Document Length: 612 bytes
    
     
    
    Concurrency Level: 3000
    
    Time taken for tests: 5.065 seconds
    
    Complete requests: 100000
    
    Failed requests: 2
    
    (Connect: 0, Receive: 0, Length: 2, Exceptions: 0)
    
    Write errors: 0
    
    Non-2xx responses: 2
    
    Total transferred: 85099032 bytes
    
    HTML transferred: 61199174 bytes
    
    Requests per second: 19744.76 [#/sec] (mean)
    
    Time per request: 151.939 [ms] (mean)
    
    Time per request: 0.051 [ms] (mean, across all concurrent requests)
    
    Transfer rate: 16408.79 [Kbytes/sec] received
    
     
    
    Connection Times (ms)
    
    min mean[+/-sd] median max
    
    Connect: 0 55 329.4 0 3008
    
    Processing: 2 25 185.9 4 3224
    
    Waiting: 1 25 185.9 4 3224
    
    Total: 3 81 433.0 4 4223
    
     
    
    Percentage of the requests served within a certain time (ms)
    
    50% 4
    
    66% 4
    
    75% 6
    
    80% 6
    
    90% 25
    
    95% 116
    
    98% 1206
    
    99% 3011
    
    100% 4223 (longest request)

    View Code

    1. 測試總結

  10. 資料彙總

    請求連線數

    併發數

    請求失敗數

    每秒處理請求數

    一次併發數請求響應時間(ms)

    全體請求完成時間(s)

    請求成功率

    10000

    1000

    11437

    87.43

    0.874

    100.00%

    50000

    2000

    1

    18593

    107.57

    2.689

    99.998%

    100000

    3000

    2

    19744

    151.94

    5.065

    99.998%

     

  11. 資料分析    

    通過測試結果可得如下分析:

    1.Nginx的每秒請求處理能力是10000+,滿足需求標準;

    2.隨著併發數的增大,一次併發請求的響應時間相應增大,滿足需求標準;

    3.隨著請求連線數的增加,相應的總體請求完成時間也增加,當請求連線數從50k增加至100k時,總體請求時間增加至2倍,具有一定的穩定性和速度性,滿足需求標準;

    4.當請求連線數和併發數依次遞增時,出現偶爾的請求失敗數,全部請求成功率大於99.99%,滿足需求標準;

    5.單臺伺服器支援3000併發正常,滿足需求標準。

          

     

————————————————————-

作者:羅穆瑞

轉載請保留此段宣告,且在文章頁面明顯位置給出原文連結,謝謝!

——————————————————————————

如果覺得這篇文章對你有小小的幫助的話,記得在右下角點個“推薦”哦,博主在此感謝!

——————————————————————————


相關文章