4

I need to benchmark a REST API that takes parameters as input. I wondering if there is a way to do it using wrk. Right now I don't see such an option:

user@Ubuntu-K56CA:~/wrk$ ./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

When I look at this file: https://github.com/wg/wrk/blob/master/src/wrk.lua

I don't see params used anywhere. Also grepping for params in wrk repo did not yield anything useful.

Am I missing something?

Akavall
  • 82,592
  • 51
  • 207
  • 251
  • [Googling](https://www.google.com/search?q="wrk"+POST+with+JSON) works for me. Among the retults it brings, [this](http://riteshkrmodi.blogspot.ru/2014/08/running-wrk.html) appears to describe exactly what you're after. – kostix Nov 05 '15 at 16:04
  • @kostix, thanks for your answer, but I don't see my answer there. The example you suggest deals with POST and it uses BODY, I want to use GET and PARAMS. – Akavall Nov 06 '15 at 03:46

1 Answers1

12

You can add it right inside url:

./wrk -c1 -t1 -d5s http://server.com/my_path?param_name=param_value

or if you want to generate it during the test you can do it with a script:

./wrk -t1 -c1 -d5s -s ./scripts/my_script.lua http://server.com

where my_script.lua is:

request = function()
  wrk.headers["Connection"] = "Keep-Alive"
  param_value = math.random(1,100)
  path = "/my_path?param_name=" .. param_value
  return wrk.format("GET", path)
end
undefined
  • 2,939
  • 4
  • 23
  • 35
Sasha
  • 1,393
  • 16
  • 17