都在谈论高并发,但是高并发系统的指标有哪些呢?
QPS(TPS)= 并发数 / 平均响应时间
并发数 = QPS * 平均响应时间
比如:
有四次请求耗时分别为:2ms,10ms,100ms,1000ms
private static int tp(List<Integer> times, int percent) { float percentF = (float)percent/100; int index = (int)(percentF * times.size() - 1);
Collections.sort(times); return times.get(index);
}
0.99 * 3 = 2.97 取整为3 第三个值为100ms
之后我们可以设置这个指标作为监控阈值,保证方法调用消耗时间少于这个值,如果超过此值,则报警。
TP90,TP99,TP999计算方法相同,代表了不同的性能要求,TP50相对较低,TP90则较高,TP99则要求很高
© 著作权归作者所有