WRK-HTTP壓力測試工的下載安裝與使用方法

 

wrk 是一款採用異步併發模型的HTTP基準測試工具:採用異步併發模型,可以發送更大且可控的壓力;內置 LuaJIT,可以經過 lua 腳本模擬常見的業務行爲,模擬更加真實的場景;相比常見的HTTP基準測試工具,佔用更少CPU、更少內存;html

支持 HTTP、 HTTPS,可以動態修改頭、修改Body方法等;支持混合場景git

編譯安裝github

  • 1.sudo yum groupinstall ‘Development Tools’
  • 2.sudo yum install openssl-devel
  • 3.sudo yum install git  #下載安裝git,並下載wrk
  • 4.git clone https://github.com/wg/wrk.git
  • 5.cd wrk
  • 6.make

基本測試方法:併發

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

  This runs a benchmark for 30 seconds, using 12 threads, and keeping
  400 HTTP connections open.

  Output:

  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:延時;
  • req/sec:每秒鐘處理的請求量
  • stdev:標準差

 

7.wrk以post方式或header方式壓測app

首先建立一個 post.lua 的文件: 異步

  • wrk.method = "POST"  
  • wrk.body   = "a=3&b=4"   #post所放參數
  • wrk.headers["Content-Type"] = "application/x-www-form-urlencoded" 
    固然header還能夠任意添加修改參數 

./wrk -t8 -c100 -d1m --script = post.lua http://localhost:8088/v2工具

post.lua文件:post

 

8.wrk以post方式或header方式壓測測試

首先建立一個 post.lua 的文件: lua

  • wrk.method = "POST"  
  • wrk.body   = ""   
  • wrk.headers["Content-Type"] = "application/x-www-form-urlencoded" 
  • wrk.headers["params1"] = "a" 
  • wrk.headers["params2"] = "b"  #header參數能夠任意添加
    固然header還能夠任意添加修改參數 
  1. 命令依然爲./wrk -t8 -c100 -d1m --script = post.lua http://localhost:8088/v2
相關文章
相關標籤/搜索