linux-wrk

linux-wrk

wrk 是一个压测工具,底层使用 epoll ,多线程执行,性能非常好

使用说明:

安装:

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

make
cp wrk /usr/local/bin

示例用法:

wrk -t12 -c400 -d30s http://127.0.0.1:8080/index.html

参数含义:

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)

示例 lua 脚本文件位置
/workspace/wrk/scripts/*.lua

wrk-lua脚本.png

-- example HTTP POST script which demonstrates setting the
-- HTTP method, body, and adding a header

wrk.method = "POST"
wrk.body   = "foo=bar&baz=quux"
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"

wrk lua 函数的生命周期

Pasted image 20220508214336.png

参考

http 性能测试 wrk使用教程
性能测试神器 wrk 使用教程


本站总访问量次 本站访客数人次 本文总阅读量