apache bench(简单压力测试)

安装:yum -y install httpd


指标:

1.吞吐率(Requests per second)

每秒处理的请求数

2.并发连接数

某个时刻服务器承受的请求数

3.并发用户

4.用户平均等待时间

计算公式:处理完成所有请求数所花费的时间/ (总请求数 / 并发用户数)

5.服务器平均请求等待时间(Time per request: across all concurrent requests)

计算公式:处理完成所有请求数所花费的时间 / 总请求数




ab -n 9000 -c 100  http://www.mi.com/ 


Requests per second:    316.93 [#/sec] (mean)(吞吐率

Time per request:       315.525 [ms] (mean)(用户等待时长

Time per request:       3.155 [ms] (mean, across all concurrent requests)(服务器平均等待时间

Transfer rate:          57635.56 [Kbytes/sec] received


ab -n 9000 -c 500  http://www.mi.com/ 

Requests per second:    321.17 [#/sec] (mean)

Time per request:       1556.825 [ms] (mean)

Time per request:       3.114 [ms] (mean, across all concurrent requests)

Transfer rate:          58401.75 [Kbytes/sec] received



ab -n 4000 -c 600  http://www.jd.com/ 

Requests per second:    301.77 [#/sec] (mean)

Time per request:       1988.272 [ms] (mean)

Time per request:       3.314 [ms] (mean, across all concurrent requests)

Transfer rate:          58411.92 [Kbytes/sec] received


ab -n 10000 -c 1000 http://master:18080/sa/

Requests per second:    6005.68 [#/sec] (mean)

Time per request:       166.509 [ms] (mean)

Time per request:       0.167 [ms] (mean, across all concurrent requests)

Transfer rate:          62681.26 [Kbytes/sec] received



在远程对web服务器进行压力测试,往往效果不理想(因为网络延时过大),建议使用内网的另一台或者多台服务器通过内网进行测试,

这样得出的数据,准确度会高很多。如果只有单独的一台服务器,可以直接本地测试,比远程测试效果要准确。