一、http_load简介
http_load是一款轻量级的web服务器压测工具,又轻巧又简便,整个安装包就10K+。它可以快速用来对网站或者Web API进行压力测试。而且功能还挺强大的,特别是在架构验证过程中,测试某个平台的并发和响应时间相当的管用。http_load并行运行多个http抓取,以测试web服务器的吞吐量。然而,与大多数这样的测试客户机不同,它在单个进程中运行,因此不会使客户机陷入困境。它也可以配置为进行https抓取。
二、安装步骤
1、下载安装包
[root@test1 opt]# wget http://acme.com/software/http_load/http_load-09Mar2016.tar.gz
2、解压安装包
[root@test1 opt]# tar -zxvf http_load-09Mar2016.tar.gz -C /usr/local/
http_load-09Mar2016/
http_load-09Mar2016/port.h
http_load-09Mar2016/version.h
http_load-09Mar2016/http_load.c
http_load-09Mar2016/timers.h
http_load-09Mar2016/FILES
http_load-09Mar2016/make_test_files
http_load-09Mar2016/README
http_load-09Mar2016/http_load.1
http_load-09Mar2016/timers.c
http_load-09Mar2016/Makefile
2、修改文件夹属主
[root@test1 opt]# cd /usr/local/
[root@test1 local]# chown -R root.root http_load-09Mar2016
3、编译安装
[root@test1 http_load-09Mar2016]# make && make install
cc -O -ansi -pedantic -U__STRICT_ANSI__ -Wall -Wpointer-arith -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wno-long-long -c timers.c
cc -O -ansi -pedantic -U__STRICT_ANSI__ -Wall -Wpointer-arith -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wno-long-long http_load.c timers.o -s -o http_load
rm -f /usr/local/bin/http_load
cp http_load /usr/local/bin
rm -f /usr/local/man/man1/http_load.1
cp http_load.1 /usr/local/man/man1
4、检查http_load命令是否安装
[root@test1 http_load-09Mar2016]# which http_load
/usr/local/bin/http_load
5、获取命令帮助
[root@test1 http_load-09Mar2016]# 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.
三、使用说明
1、语法格式
http_load <参数> <url列表文件>
2、参数说明
-
-parallel 简写 -p: 同一时间发起的并发连接数
-
-rate 简写 -r: 每秒开启的并发连接数,最大1000
parallel或-rate必须且只能有一个 -
-fetches 简写 -f :总计的访问次数
-
-seconds 简写 -s :总计的访问时间
-fetches或-seconds必须且只能有一个 -
-proxy host:port: 指定需经过的代理地址和端口
-
-timeout secs: 连接闲置后多久超时,默认60秒
-
-verbose: 控制台输出详细信息
3、使用示例
- 200个并发运行100秒
[root@test1 http_load-09Mar2016]# cat url2.txt
http://www.baidu.com
244 fetches, 200 max parallel, 7.48676e+07 bytes, in 10 seconds
306834 mean bytes/connection
24.4 fetches/sec, 7.48675e+06 bytes/sec
msecs/connect: 156.13 mean, 1156.09 max, 15.518 min
msecs/first-response: 168.185 mean, 886.648 max, 21.107 min
240 bad byte counts
HTTP response codes:
code 200 – 244
- 每秒1000个连接访问10000次
[root@test1 http_load-09Mar2016]# http_load -r 1000 -f 10000 url2.txt
…
http://www.bigdatayh.com/index.html: Operation already in progress
http://www.bigdatayh.com/index.html: byte count wrong
10006 fetches, 1066 max parallel, 5.22525e+07 bytes, in 11.0687 seconds
5222.11 mean bytes/connection
903.993 fetches/sec, 4.72076e+06 bytes/sec
msecs/connect: 862.442 mean, 7191.1 max, 5.061 min
msecs/first-response: 308.481 mean, 9072.42 max, 0.204 min
4327 bad byte counts
HTTP response codes:
code 200 – 5679
- 每秒500个连接,运行时间180秒
[root@test1 local]# http_load -r 500 -s 180 url2.txt
http://www.bigdatayh.com/index.html: timed out
http://www.bigdatayh.com/index.html: byte count wrong
http://www.bigdatayh.com/index.html: timed out
http://www.bigdatayh.com/index.html: byte count wrong
http://www.bigdatayh.com/index.html: timed out
http://www.bigdatayh.com/index.html: byte count wrong
http://www.bigdatayh.com/index.html: timed out
http://www.bigdatayh.com/index.html: byte count wrong
http://www.bigdatayh.com/index.html: timed out
http://www.bigdatayh.com/index.html: byte count wrong
89837 fetches, 712 max parallel, 8.26544e+08 bytes, in 180 seconds
9200.49 mean bytes/connection
499.094 fetches/sec, 4.59191e+06 bytes/sec
msecs/connect: 297.249 mean, 31202.8 max, 4.439 min
msecs/first-response: 119.458 mean, 40542.5 max, 8.254 min
5 timeouts
5 bad byte counts
HTTP response codes:
code 200 – 89832
4、结果参数说明
- bytes/connection 每个连接传输的数据量
- fetches/sec 每秒响应的连接数
- msecs/connect 连接响应时间,mean是平均响应时间,max是最大响应时间,min是最小响应时间。