Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to pass parameters to GET request using wrk?

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?

like image 753
Akavall Avatar asked Jan 08 '23 05:01

Akavall


1 Answers

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
like image 147
Sasha Avatar answered Mar 06 '23 22:03

Sasha