1. 程式人生 > >LAF後端效能測試(ab)

LAF後端效能測試(ab)

LAF後端效能測試

1)首頁第一頁載入:

併發量50
Document Path: /service/api/v1/item?page=0
Document Length: 2965 bytes
Concurrency Level: 50
Complete requests: 1000
Failed requests: 2
Requests per second: 11.30[#/sec] (mean)
Time per request: 4425.834[ms] (mean)
Transfer rate: 34.41[Kbytes/sec] received
Percentage of the requests served within a certain time (ms)
50% 1254
75% 2482
80% 3304


100% 60823(longest request)

併發量:60
Document Path: /service/api/v1/item?page=0
Document Length: 2965 bytes
Concurrency Level: 60
Complete requests: 1000
Failed requests: 7
Requests per second: 13.58[#/sec] (mean)
Time per request: 4417.343[ms] (mean)
Transfer rate: 41.16[Kbytes/sec] received
Percentage of the requests served within a certain time (ms)
50% 1460
75% 3308
80% 3934


100% 73620(longest request)

2) 圖片載入速度
DocumentPath: /service/static/uploads/admin/default_avatar.jpg
Document Length: 12391 bytes
Concurrency Level: 50
Complete requests: 1000
Failed requests: 19
Requests per second: 6.87[#/sec] (mean)
Time per request: 7282.662[ms] (mean)
Transfer rate: 82.52[Kbytes/sec] received
(頻寬為1Mbps, 理想傳輸速率為125 Kbytes/sec,這時候頻寬已經[快]成為瓶頸)
Percentage of the requests served within a certain time (ms)
50% 2692
66% 4120
75% 5142
80% 6370


100% 86614(longest request)
這個圖片還是比較小的圖片,才12KB,一般來說是20+KB, 如果是手機裡的原圖,壓縮後一般在120+KB,預計可能達上MB。

併發量20
Docum Path: /service/static/uploads/admin/default_avatar.jpg
Document Length: 12391 bytes
Concurrency Level: 20
Complete requests: 500
Requests per second: 6.66[#/sec] (mean)
Time per request: 3004.820[ms] (mean)
Transfer rate: 81.55[Kbytes/sec] received
Percentage of the requests served within a certain time (ms)
50% 1652
80% 3987
100% 30340(longest request)

訪問圖片併發量 30
Path: /service/static/uploads/admin/default_avatar.jpg
Document Length: 12391 bytes
Concurrency Level: 30
Complete requests: 500
Failed requests: 5

Requests per second: 6.87[#/sec] (mean)
Time per request: 4366.394[ms] (mean)
Transfer rate: 83.34[Kbytes/sec] received
Percentage of the requests served within a certain time (ms)
50% 2096
66% 2949
75% 3970
80% 4732
100% 66365 (longest request)
可見,圖片訪問的併發量在20到30之間可勉強接受。而且圖片訪問的吞吐率好底阿,6.x requests/sec

併發需求估計:
一、經典公式
1)平均併發使用者數為 C = nL/T
2)併發使用者數峰值 C‘ = C + 3*根號C
C是平均併發使用者數,n是login session的數量,L是login session的平均長度,T是值考察的時間長度 C’是併發使用者數峰值
假設使用者線上數100,平均訪問時長5分鐘,即1/12小時。則平均併發使用者數為:100*1/12*8 = 8.x; 峰值為 8 + 3*2 = 14。首頁滿足要求,釋出頁面待測試

二、根據系統使用者數計算
併發使用者數 = 系統最大線上使用者數的8%到12%
假設最大線上使用者數為1000,則併發量達100。暫時達不到。(升級頻寬至4M後可達到)

高峰期所需的頻寬估算:
公式:併發數 * 為每個連線提供的頻寬
根據測試,平均頻寬為40Kbytes/sec
如果併發數為100,則頻寬要求為: 100 * 40KB/1024KB = 4Mbps

###總結:首頁訪問併發量 50, 圖片訪問併發量 20 ~ 30。顯然太低。優化思路: 1. 圖片資源改由nginx處理,不在走uwsgi 處理。2.提高吞吐率,目前不清楚怎麼提高(可能要提升伺服器配置,修改nginx及系統的配置選項等)。 3. 提高頻寬(4M)。

頻寬提高到4M後:

首頁第一頁,併發量50:
TLS Server Name: ikebo.cn
Document Path: /service/api/v1/item?page=0
Document Length: 2916 bytes
Concurrency Level: 50
Complete requests: 1000
Requests per second: 35.04[#/sec] (mean)
Time per request: 1426.972[ms] (mean)
Time per request: 28.539[ms] (mean, across all concurrent requests)
Transfer rate: 105.25[Kbytes/sec] received

Percentage of the requests served within a certain time (ms)
80% 1385
100% 1583(longest request)

併發量 100:
TLS Server Name: ikebo.cn
Document Path: /service/api/v1/item?page=0
Document Length: 2916 bytes

Concurrency Level: 100
Complete requests: 1000
Failed requests: 1
Requests per second: 20.22[#/sec] (mean)
Time per request: 4945.459[ms] (mean)
Transfer rate: 60.74[Kbytes/sec] received
Percentage of the requests served within a certain time (ms)
80% 2718
100% 23745 (longest request)

圖片載入 併發量50:
TLS Server Name: ikebo.cn
Document Path: /static/uploads/admin/default_avatar.jpg
Document Length: 12391 bytes

Concurrency Level: 50
Complete requests: 1000
Failed requests: 2
Requests per second: 13.37[#/sec] (mean)
Time per request: 3741.087[ms] (mean)
Transfer rate: 164.94[Kbytes/sec] received
Percentage of the requests served within a certain time (ms)
80% 2271
100% 22666 (longest request)

可見,頻寬從1M升級到4M之後,效能顯著提升,首頁載入從原來的50~60提升到100+, 圖片載入速度從原來的20~30提升到50+