使用http_load工具测试Web吞吐量

来源:互联网 发布:2016网络理财排行榜 编辑:程序博客网 时间:2024/06/03 17:04
使用http_load工具测试Web吞吐量

http_load并行地运行多个http fetches以测试Web server的吞吐量。它只需要一个进程,不会对client造成太大影响。使用之前,需要准备一个文件,里面是URL列表。还需要指定如何开始连接(是指定rate或者指定paralle),以及指定如何退出(是指定fetch总量,还是指定时间)

1. 下载与安装

下载地址:
http://www.acme.com/software/http_load/
下载的文件名为 http_load-09Mar2016.tar.gz

解压之后安装:
root@db2a:~# cd http_load-09Mar2016
root@db2a:~/http_load-09Mar2016# make && make install

2. 测试

root@db2a:~# http_load help
usage: http_load [-checksum] [-throttle] [-proxy host:port] [-verbose] [-timeout secs] [-sip sip_file]
-parallel N | -rate N [-jitter]
-fetches N | -seconds N
url_file
One start specifier, either -parallel or -rate, is required.
One end specifier, either -fetches or -seconds, is required.

-fetches:总计要访问url的次数,无论成功失败都记为一次,到达数量后程序退出。
-rate:每秒访问的次数(即访问频率),控制性能测试的速度。
-seconds:工具运行的时间,到达seconds设置的时间后程序退出。
-parallel:最大并发访问的数目,控制性能测试的速度。

其中-parallel参数和-rate参数中必须有一个,用于指定发请求包的方式;-fetches和-seconds两个参数必须有一个,用于指定程序的终止条件。

root@db2a:~# cat blog.url
http://blog.csdn.net/
http://blog.csdn.net/qingsong3333
http://blog.csdn.net/qingsong3333/article/details/77871890
http://blog.csdn.net/qingsong3333/article/details/77757697
http://blog.csdn.net/qingsong3333/article/details/77756042
http://blog.csdn.net/qingsong3333/article/details/77726215
http://blog.csdn.net/qingsong3333/article/details/77726074

下面的命令以尽可能快的速度,请求blog.url里指定的url:
root@db2a:~# http_load -parallel 1 -seconds 10 blog.url
459 fetches, 1 max parallel, 847986 bytes, in 10.0039 seconds
1847.46 mean bytes/connection
45.882 fetches/sec, 84765.3 bytes/sec
msecs/connect: 11.4411 mean, 47.94 max, 9.128 min
msecs/first-response: 4.15948 mean, 791.331 max, 1.699 min
HTTP response codes:
code 200 -- 459

===
459 fetches, 1 max parallel, 847986 bytes, -> 表示有459次请求,并发为1,共传输数据847986 bytes,运行时间10.0039秒
1847.46 mean bytes/connection, -> 每个连接的数据量为1847.46,计算方法为847986/459
45.882 fetches/sec, 84765.3 bytes/sec -> 每秒种的请求数为45.882,传输的数据量为84765.3 bytes
msecs/connect: 11.4411 mean, 47.94 max, 9.128 min ->连接平均响应时间为11.4411

并发设置为5:
root@db2a:~# http_load -parallel 5 -seconds 10 blog.url
2026 fetches, 5 max parallel, 3.74155e+06 bytes, in 10.0055 seconds
1846.77 mean bytes/connection
202.489 fetches/sec, 373951 bytes/sec
msecs/connect: 12.338 mean, 52.168 max, 9.036 min
msecs/first-response: 2.46339 mean, 59.519 max, 1.417 min
HTTP response codes:
code 200 -- 2026

指定每秒钟访问次数为5:
root@db2a:~# http_load -rate 5 -seconds 10 blog.url
49 fetches, 1 max parallel, 90522 bytes, in 10.0025 seconds
1847.39 mean bytes/connection
4.89877 fetches/sec, 9049.93 bytes/sec
msecs/connect: 14.296 mean, 59.613 max, 9.998 min
msecs/first-response: 2.63614 mean, 6.246 max, 1.771 min
HTTP response codes:
code 200 -- 49

附:还有一个http_ping工具,下载链接如下:
http://www.acme.com/software/http_ping/

作用是:http_ping is like the regular ping command, except that it sends HTTP requests instead of ICMP echo requests.

示例:
root@db2a:~/http_ping# http_ping http://blog.csdn.net/qingsong3333
1831 bytes from http://blog.csdn.net/qingsong3333: 25.773 ms (23.193c/2.357r/0.223d)
1831 bytes from http://blog.csdn.net/qingsong3333: 42.045 ms (40.011c/1.942r/0.092d)
1831 bytes from http://blog.csdn.net/qingsong3333: 13.903 ms (11.954c/1.859r/0.09d)
1831 bytes from http://blog.csdn.net/qingsong3333: 14.429 ms (12.22c/2.01r/0.199d)
1831 bytes from http://blog.csdn.net/qingsong3333: 15.111 ms (12.483c/2.579r/0.049d)
1831 bytes from http://blog.csdn.net/qingsong3333: 16.631 ms (14.16c/2.419r/0.052d)
^C
--- http://blog.csdn.net/qingsong3333 http_ping statistics ---
6 fetches started, 6 completed (100%), 0 failures (0%), 0 timeouts (0%)
total min/avg/max = 13.903/21.3153/42.045 ms
connect min/avg/max = 11.954/19.0035/40.011 ms
response min/avg/max = 1.859/2.19433/2.579 ms
data min/avg/max = 0.049/0.1175/0.223 ms

参考资料《高性能MySQL》
阅读全文
0 0