目录

wrk系列教程(1)安装

wrk是一个高性能的性能测试工具,具有非常强的并发能力,很适合做benchmark。

wrk适合做一些简单的单接口性能压测,具有一定的扩展能力,不太适合做全链路的带业务压测。

下载源码

首先你需要1台linux虚拟机或者mac机器。

如果你用使用git,可以使用下面命令来下载源码

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

或者你可以使用wget来下载源码的压缩包,并自行解压

wget https://github.com/wg/wrk/archive/master.zip

安装wrk

cd到wrk源码所在目录,运行

make

如果一切正常,一段时间后wrk会自动编译完成。我们可以将编译出的wrk可执行文件拷贝到/usr/local/bin中,这样调用起来会比较方便。

如果需要定制化安装,你可以参考这里

验证安装

运行wrk可执行程序,你应该看到下面的结果

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)

原始封面

https://images.unsplash.com/photo-1511091734515-e50d46c37240?w=300