-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow ramping down of users #1502
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1502 +/- ##
==========================================
- Coverage 81.44% 81.28% -0.17%
==========================================
Files 27 27
Lines 2388 2410 +22
Branches 367 372 +5
==========================================
+ Hits 1945 1959 +14
- Misses 352 359 +7
- Partials 91 92 +1
Continue to review full report at Codecov.
|
locust/runners.py
Outdated
user.stop(self.user_greenlets, force=True) | ||
|
||
stop_group.add(user_to_stop._greenlet) | ||
if not stop_group.join(timeout=self.environment.stop_timeout): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This timeout will potentially prolong the iteration time for this while loop.
So if you had for example stop_rate 1 and stop_timeout 2, you would end up (if no users stopping within the timeout) taking 3 seconds to complete an iteration (giving you a stop rate of 1/3 users per second).
I dont think that is what our users would would expect.
Ideally these things should be done async (I guess you'll have to spawn "killer greenlets" or something)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I see what you mean.
What is we just do stop_group = Group()
outside the loop and then stop_group.kill(block=True)
after loop is done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! Can you add a test for it? I think it is one of those things that could trip us up :) (now or in the future)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can but what exactly is the test? Ramping down with stop_timeout
set? How does the test fail? If ramping down doesn't happen? Or it happens too slowly?
If I understand correctly, if stop_timeout
is set, we can't really guarantee any ramp down rate accurately, but could do best effort.
Well, in my worst-case example, we should still be stopping roughly 1 user per second, over time (except at the very last step where we last users will take around 1s extra) For example, if we have 4 users and 2s timeout, it should take 6s to ramp down to zero if no users finish their iteration in time and ramp down is 1/s (and the iterations should be killed after 2 seconds and not sooner) (the current implementation would take 13s i think) Also, you can use a faster ramp down rate to make the test take less time than in my example :) |
@cyberw OK I've added a second test under |
This test is too lenient:
After 2.1 seconds of ramp down at 2/s and with one second delay I would expect to see 6 users running, any more than that is an error. You can run higher ramp down rate to shorten the test. |
OK fair enough. I did some testing and did see some variation, like +/- 1 when using whole numbers for sleeping. So I increased the hatch rate to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great now. Only thing left is some documentation + an example.
🎉
Can you give me a hint here? I've looked through the docs and there's nothing really specifically mentioning hatch rate when decreasing users, decreasing users at all or really anything specific about hatch rate. And what kind of example would I show? |
I think for the web gui it is kind of supposed to be self explanatory, so maybe a note there about the hatch rate affecting both up and down ramping (tbh I'm not much of a web user myself). Maybe there should be a an example similar to the unit test in /examples as well? (edit: ignore what I previously wrote) |
OK true. I made some small changes to the wording around starting and editing a test.
I don't think this is possible? The examples are all various types of locust files and you can't edit a running test in them. Or really do anything to show "ramping down" I don't think. I think this will be addressed in my other PR which we are also close to merging 😉 |
Nice! |
Resolves: #1488
stop_user_instances()
intostop_users()
stop_rate
to be passed tostop_users()
stop_rate
does the same thingspawn_users()
, it seems robuststop_rate
passed tostop_users()
then don't "ramp down", just stop all without sleepinguser_count
/hatch_rate
valuesThis is my first proper PR for this project so any and all feedback welcome 🙂
I have still yet to update any documentation...