http接口压测工具wrk

wrk是一款简单的HTTP压测工具,当运行在单个多核CPU上时,它能够产生巨大的负载。

github:https://github.com/wg/wrk

国内镜像: https://gitee.com/mirrors/wrk

安装:

git clone https://github.com/wg/wrk.git
cd wrk
make

# 将可执行文件移动到 /usr/local/bin 位置
sudo cp wrk /usr/local/bin

查看版本:

[root@node1 wrk]# wrk -v
wrk 4.1.0-8-ga211dd5 [epoll] Copyright (C) 2012 Will Glozer
Usage: wrk <options> <url>
  Options:
    -c, --connections <N>  Connections to keep open
    -d, --duration    <T>  Duration of test
    -t, --threads     <N>  Number of threads to use

    -s, --script      <S>  Load Lua script file
    -H, --header      <H>  Add header to request
        --latency          Print latency statistics
        --timeout     <T>  Socket/request timeout
    -v, --version          Print version details

  Numeric arguments may include a SI unit (1k, 1M, 1G)
  Time arguments may include a time unit (2s, 2m, 2h)

可以看到wrk的用法,相对来说比较简单;

接下来使用wrk来压测下百度首页,

使用20个线程100个连接进行30s的压测:

wrk -t20 -c100 -d30s http://www.baidu.com 

 压测下本地的接口:

wrk -t20 -c100 -d30s --latency http://127.0.0.1:9000

 以上是wrk的基本用法,还可以使用lua脚本进行个性化压测,有兴趣的可以研究下。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值