Linux之压测工具http_load安装和使用

http_load是一个小巧的web服务器压力测试工具,用于测试网站或WebAPI的并发和响应时间。本文介绍了其安装步骤,包括下载、解压、修改文件属主、编译和安装,并提供了详细的使用说明及参数解释,例如并发连接数、每秒连接数、总访问次数等。通过示例展示了不同场景下的压力测试操作。
摘要由CSDN通过智能技术生成

一、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是最小响应时间。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

恒悦sunsite

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值