introduce delay in vegeta requests

338 Views Asked by At

I want to introduce a delay between the POST requests using Vegeta. I believe reducing the '-rate' number is not the right way as it is the number of requests I want to have. Is there any way to include delay/sleep between the requests?

1

There are 1 best solutions below

2
Eric On

That's a great question; I have been looking for the same, but did not see any such option (yet) -- what I have considered (but cannot test now):

  • create a script genload.sh that prints the requests-to-do to stdout in json format (as defined by vegeta), in your desired timed manner (lines appear with the rhythm you want). It could even be just a shell line:

    while true; do echo '{method: "GET", url: "http://goku", body: "Punch!" | @base64, header: {"Content-Type": ["text/plain"]}}'; sleep 0.05 | done

    (of course this just does 20 req/s, so you'll want to more advanced logic for your usecase)

  • execute the request-generator, streaming to vegeta as request-executor: ./genload.sh | vegeta -lazy -target /dev/stdin -format json (.. more options ..)

I do not know

  • if this will work -- that is, if vegeta will now obey to the rhythm dictated by your ./genload.sh script. If you try, let me know!
  • to what extent this will introduce new performance bottleneck
  • whether this will make your life easier, now that you have to maintain a script generating the load.

If it works, let me know!