天天看点

wrk-服务器压力测试工具的使用(一)

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

一、安装

Ubuntu/Debian

$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev git -y
$ git clone https://github.com/wg/wrk.git wrk
$ cd wrk
$ sudo make

//move the executable to somewhere in your PATH, ex:
$ sudo cp wrk /usr/local/bin
           

CentOS / RedHat / Fedora

$ sudo yum groupinstall'Development Tools'
$ sudo yum install openssl-devel
$ sudo yum install gitgit clone https://github.com/wg/wrk.git wrk
$ cd wrk
$ make

//move the executable to somewhere in your PATH
$ sudo cp wrk /somewhere/in/your/PATH
           

其他系统参考:https://github.com/wg/wrk/wiki

二、使用

wrk的使用非常简单

一行命令搞定

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

// 运行30s,开启12线程,总共保持400个HTTP连接开启

三、wrk报告

Running 30s test @ http://127.0.0.1:8080/index.html

12 threads and 400 connections

Thread Stats  Avg      Stdev    Max  +/- Stdev

Latency  635.91us    0.89ms  12.92ms  93.69% 

Req/Sec    56.20k    8.07k  62.00k    86.54%

22464657 requests in 30.00s, 17.76GB read

Requests/sec: 748868.53

Transfer/sec:    606.33MB
           

结果也不难理解。

latency那一行反映了请求响应时间,分别为平均值,标准差,最大值,正负一个标准差内的比例;

transfer为数据交换量。

其他都很好理解,无须解释了。