并发量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)。
首页第一页,并发量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+