HTTP 性能测试工具 wrk 使用介绍

发布时间: 更新时间: 总字数:295 阅读时间:1m 作者: IP属地: 分享 复制网址
专栏文章
  1. Web性能压力测试工具——Siege详解
  2. HTTP 性能测试工具 wrk 使用介绍(当前)

wrk 是一款针对 Http 协议的基准测试工具,它能够在多核 CPU 的条件下,使用系统自带的高性能I/O 机制,通过多线程和事件模式,对目标网址产生大量的请求,已到达测试网址性能的目的。

安装

git clone https://github.com/wg/wrk
make
cp wrk /usr/local/bin/

使用

$ wrk --help
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)
-c, --connections: total number of HTTP connections to keep open with
                   each thread handling N = connections/threads

-d, --duration:    duration of the test, e.g. 2s, 2m, 2h

-t, --threads:     total number of threads to use

-s, --script:      LuaJIT script, see SCRIPTING

-H, --header:      HTTP header to add to request, e.g. "User-Agent: wrk"

    --latency:     print detailed latency statistics

    --timeout:     record a timeout if a response is not received within
                   this amount of time.

demo

$ wrk -t12 -c40 -d30s http://baidu.com
Running 30s test @ http://baidu.com
  12 threads and 40 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    33.41ms    1.75ms  38.48ms   72.73%
    Req/Sec    65.24     25.72   110.00     79.66%
  385 requests in 30.08s, 145.13KB read
  Socket errors: connect 0, read 9962, write 0, timeout 0
Requests/sec:     12.80
Transfer/sec:      4.82KB
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数