http_load 小试牛刀
Last updated: Oct 219, 21029
问
如何对一个应用进行整体的测试?
答
可以使用 http_load 工具
创建文件
创建一个文件 http_urls,内容是:
https://www.percona.com/blog/
https://www.baidu.com
http://youdao.com/
模拟单用户
执行如下命令:
http_load -parallel 1 -seconds 10 http_urls
结果:
9 fetches, 1 max parallel, 100340 bytes, in 10.2233 seconds
11148.9 mean bytes/connection
0.880343 fetches/sec, 9814.85 bytes/sec
msecs/connect: 53.9417 mean, 286.954 max, 15.097 min
msecs/first-response: 142.392 mean, 898.593 max, 29.578 min
HTTP response codes:
code 200 – 9
解释
- -parallel:并发的用户进程数
- -rate:每秒的访问频率
- -seconds:总计的访问时间
9 fetches, 1 max parallel, 100340 bytes, in 10.2233 seconds
运行了 9 次请求,最大并发进程数是 1
总计传输数据是 100340 比特,运行时长 10.2233 秒
11148.9 mean bytes/connection
每条连接平均传输的数据量是 11148.9 比特
0.880343 fetches/sec, 9814.85 bytes/sec
每秒响应请求数是 0.880343,每秒传递数据为 9814.85 比特
msecs/connect: 53.9417 mean, 286.954 max, 15.097 min
每条连接平均响应时间是 53.9417 msecs
最大响应时间是 286.954 msecs
最小响应时间是 15.097 msecs
msecs/first-response: 142.392 mean, 898.593 max, 29.578 min
第一条响应平均响应时间是 142.392 msecs
最大响应时间是 898.593 msecs
最小响应时间是 29.578 msecs
code 200 – 9
打开响应页面的类型,如果 403 的类型过多,注意系统是否遇到瓶颈
模拟多用户
执行如下命令:
http_load -parallel 6 -seconds 10 http_urls
结果:
8 fetches, 6 max parallel, 1816 bytes, in 11.0792 seconds
227 mean bytes/connection
0.722076 fetches/sec, 163.911 bytes/sec
msecs/connect: 1153.94 mean, 8956.7 max, 14.686 min
msecs/first-response: 1760.54 mean, 5686 max, 161.341 min
HTTP response codes:
code 200 – 8
模拟访问请求率
执行如下命令:
http_load -rate 5 -seconds 10 http_urls
结果:
4 fetches, 11 max parallel, 9068 bytes, in 10.0739 seconds
2267 mean bytes/connection
0.397064 fetches/sec, 900.144 bytes/sec
msecs/connect: 946.488 mean, 3718.64 max, 16.022 min
msecs/first-response: 1253.54 mean, 4865.31 max, 36.755 min
HTTP response codes:
code 200 – 4
提高访问请求率
执行如下命令:
http_load -rate 20 -seconds 10 http_urls
结果:
9 fetches, 12 max parallel, 18363 bytes, in 11.8324 seconds
2040.33 mean bytes/connection
0.760625 fetches/sec, 1551.93 bytes/sec
msecs/connect: 1493.96 mean, 7119.51 max, 17.047 min
msecs/first-response: 793.016 mean, 2663.34 max, 52.493 min
HTTP response codes:
code 200 – 9