接口压测

怎么都测不过,一次请求要5、6秒,我着实惊讶

1 经过多翻调查,先ping redis和drds,发现ping值要3毫秒左右,经过调整vpc到一个网段后,解决0.x毫秒为正常ping

2 将for使用parellel实现并行

3 自测发现2百毫秒,而在压测环境在6百毫秒,经过调查发现压测环境用的debug级别日志,通过阻塞io增加了延迟,这是一个大坑

自测命令yum install httpd-tools,然后通过

ab -n 1000 -c 80 -H 'resourceScale: 1' 'http://xx/api'

Requests per second: 566.39 [#/sec] (mean)
Time per request: 176.556 [ms] (mean)
Time per request: 1.766 [ms] (mean, across all concurrent requests)
Transfer rate: 2385.05 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 17
Processing: 48 175 22.2 173 342
Waiting: 45 175 22.2 173 342
Total: 48 175 22.2 173 344

Percentage of the requests served within a certain time (ms)
50% 173
66% 180
75% 186
80% 190
90% 204
95% 217
98% 232
99% 244
100% 344 (longest request)

其中第一个Time per request为平均用户感知速度,应该是可用的 90%是压测team值用的参考值。

done

原文地址:https://www.cnblogs.com/a-xu/p/9791526.html