httperf使用入门

安装:./configure --prefix=/usr/local/httperf (默认prefix为/usr/local); make; make install
安装后在/usr/local/bin下有httperfidleconn;idleconn建立的是空闲连接,连接被Server断开后,重新再建立,保持固定数目的TCP链接

本机80端口建立100个TCP连接:
    idleconn 127.0.0.1 80 100

本机80端口建立20个TCP连接,每秒10个连接,每连接1个HTTP请求:
    httperf --server 127.0.0.1 --port 80 --num-conns 20 --rate 10

详细参数列表,可以参考http://linux.die.net/man/1/httperf以及官方文档。总的来说,有2种产生负载的模式,session-oriented & request-oriented。session-oriented模式可以通过自定义配置文件,灵活模拟用户通过浏览器访问网站过程,而request-oriented模式产生workload的模式比较单一。需要注意的几个参数:

--hog
根据需求,用尽尽可能多的TCP端口;如果不加,则只使用ephemeral ports (in the range from 1024 to 5000)

--time-out
取值参考2点:1. 真实用户的等待时间(time-out should probably be somewhere between 5 and 10 seconds - research has indicated that most people will give up on a site if it takes more than 8 seconds to download a page.2. Client 产生流量的速率,如果不释放连接,可能很快耗尽fd(httperf could potentially quickly use up all available file descriptors, at which point it could not induce any new load on the server)


httperf命令输出信息分为6个部分:

1. 测试整体数据
Total: connections 1000 requests 1000 replies 1000 test-duration 40.037 s
    建立了TCP连接总数,HTTP request总数,以及得到HTTP reply总数

2. TCP连接数据
Connection rate: 25.0 conn/s (40.0 ms/conn, <=975 concurrent connections)
    每秒新建连接数(CPS),期间最大同一时刻并发连接数
Connection time [ms]: min 502.7 avg 29377.2 max 36690.2 median 30524.5 stddev 5620.5
    成功的TCP链接的生命周期(成功建立,并且至少1request1reply),计算median是用histogram方法,统计粒度为1ms
Connection time [ms]: connect 93.6
    成功建立的TCP连接的链接建立平均时间(有可能http request发出单并不replay,最终失败)
Connection length [replies/conn]: 1.000
    平均每个TCP链接收到的HTTP reply数目

3. HTTP请求数据
Request rate: 25.0 req/s (40.0 ms/req)
    每秒HTTP请求数,若没有persistent connections(持久链接),则HTTP RequestConnect指标基本一致
Request size [B]: 67.0
    HTTP请求body大小

4. HTTP响应数据
Reply rate [replies/s]: min 1.8 avg 24.3 max 127.2 stddev 42.8 (8 samples)
    每秒收到的HTTP reply数目。每5s采集一个sample,建议至少30sample,也就是跑150s以上
Reply time [ms]: response 85.9 transfer 29197.6
    response 代表从发送http request到接受到reply的间隔时间,transfer表示接到reply直到结束消耗的时间
Reply size [B]: header 219.0 content 4694205.0 footer 2.0 (total 4694426.0)
Reply status: 1xx=0 2xx=1000 3xx=0 4xx=0 5xx=0
    Reply状态码以及Body Size统计

5. 混杂的数据
CPU time [s]: user 1.10 system 38.88 (user 2.8% system 97.1% total 99.9%)
    如果total值远远小于100%,代表其他进程同时在runresults are "polluted" and the test should be rerun
Net I/O: 114505.2 KB/s (938.0*10^6 bps)
    计算TCP连接中发送和接收的payloadMbps

6. 错误数据
Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
    第1行的错误很有可能是server端的瓶颈。client-timoconnrefused错误说明很有可能被测server达到瓶颈,处理慢或者dropclient请求(也可能是自己time-out参数设置太短)。而fd-unavail说明本机FD不够用了,看看ulimit -naddrunavail说明client用完了TCP端口,检查net.ipv4.ip_local_port_range以及执行httperfratetimeoutnum-conns参数的配合。如果other不为0,则在安装./configurej阶段加入--enable-debug,运行时加--debug 1看看。

转载于:https://my.oschina.net/chenzhuo/blog/148666

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值