Closed Kimserey closed 5 years ago
Perhaps you’d find the new JSON target format easier to produce?
Thanks for the reply @tsenart , yes JSON target format will definitely make it easier.
But I am still trying to understand how does -lazy
work. For example if I make a script that prints every 10 seconds a JSON formatted target for a period of 1 minute, does that mean that vegeta
will attack every 10 seconds for a duration of 1 minute?
Would the following be the right command?
> my_script_generator.sh | vegeta -lazy
Your script should produce targets as fast as it can with no sleeping in between targets.
Your script should produce targets as fast as it can with no sleeping in between targets.
Got it, and vegeta
would select the latest target generated?
No. Your generator blocks if vegeta attack is too slow to consume targets. On the other hand, if vegeta attack is too fast, it won’t be able to sustain your desired request rate. Generated targets are not dropped. By the way, if you use CTRL-C to stop the attack, it’s normal to see a broken pipe error; basically it’s your generator that is trying to write to a closed pipe, because vegeta already quit.
Your generator blocks if vegeta attack is too slow to consume targets. On the other hand, if vegeta attack is too fast, it won’t be able to sustain your desired request rate.
Oh okay, my bad, this was due to my misunderstanding of how pipe worked.
So if I were to create a test for a duration of 10 minutes, the requirements for the generator would be:
Otherwise the command my_script_generator.sh | vegeta -lazy -rate=10 -duration=10m
will never stop right?
Asking because I'd like to pipe it then to a result file my_script_generator.sh | vegeta -lazy -rate=10 -duration=10m > results.bin
. At some point in time, my_script_generator.sh
has to terminate by itself in order to have the whole command completed.
Yes to point number 1. The second isn’t needed. vegeta attack will stop after 10 minutes and your script will fail to write to stdout with the broken pipe error.
It doesn't seem to stop I am on Windows running vegeta
v12.1.0. It will wait until my generator completes. If the generator never completes, I have to CTRL+C.`
I've created a generator using dotnet
which is basically a console application writing on standard output infinitely and running with the following command on CMD:
dotnet mygenerator.dll | vegeta -lazy -rate=10 -duration=10m
But this question can be closed, as I understand now how to get -lazy
to work.
Just to clarify a bit further, the generator wouldn't need run for a special duration - it would only need to ensure the rate and the amount of targets to be generated.
For example if I were to run a test for 10 rps
for a duration of 1 min
, the requirements for the generator would be that it needs to generate 600 targets (10 rps * 60 sec)
, it will then terminate naturally and vegeta
will read the targets at its own rate.
Vegeta reads targets on demand when -lazy=true. You can use buffered IO to stdout or not. If you don’t, then your script will block waiting between each target read.
Question
I would like to generate random body for each POST requests executed. I read the post from thisdata.com and the issues linked to that random body scenario and saw that it all pointed to having a generator providing a stream of input to vegeta using
-lazy
option.I understand that it can be written in any language/script but I am having a hard time to understand how to write one and even find an example of a generator that could be piped to vegeta.
Would you have an existing example?