-
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
#1884 User distribution should happen when new workers comes in #1886
Conversation
I only had a quick look, but I dont see anything bad about this. |
report.html
Outdated
@@ -0,0 +1,353 @@ | |||
<!DOCTYPE html> |
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.
Was this file committed inadvertently?
I know I said yesterday that the background task was my preferred solution, but looking back at the code, I remembered I started to implement it in a more efficient fashion. It is more efficient because rebalancing only takes place whenever a new worker joins or if a worker goes missing instead of always rebalancing even if there's nothing to rebalance. It is also faster to react because it acts immediately upon a worker joining or missing. The logic for a worker joining goes here: Lines 880 to 883 in bb77344
The logic for a worker that goes missing goes here: Line 834 in bb77344
|
Also note that because of a regression I introduced in #1809 and that was reported in #1883, the |
@mboutet indeed it would make more sense to implement it in the event, currently I have added a new integration test, it would currently fail without my changes, but I will try to fix it in the event code instead. |
I saw in one of your latest commit that you removed the |
@mboutet ok sure I will add it back |
Can you address the comment I left: #1886 (comment) |
locust/runners.py
Outdated
@@ -637,6 +638,9 @@ def on_quitting(environment, **kw): | |||
|
|||
self.environment.events.quitting.add_listener(on_quitting) | |||
|
|||
def rebalancingEnabled(self): |
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.
def rebalancingEnabled(self): | |
@property | |
def rebalancing_enabled(self) -> bool: |
locust/runners.py
Outdated
# # TODO: Necessary now that UsersDispatcher handles that? | ||
# # balance the load distribution when new client joins | ||
# self.start(self.target_user_count, self.spawn_rate) | ||
if self.rebalancingEnabled() and self.state == STATE_RUNNING and self.spawning_completed: |
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.
if self.rebalancingEnabled() and self.state == STATE_RUNNING and self.spawning_completed: | |
if self.rebalancing_enabled and self.state == STATE_RUNNING and self.spawning_completed: |
locust/argument_parser.py
Outdated
action="store_true", | ||
default=False, | ||
dest="enable_rebalancing", | ||
help="Allow to automatically rebalance users if new workers are added after ramp up completed.", |
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.
help="Allow to automatically rebalance users if new workers are added after ramp up completed.", | |
help="Allow to automatically rebalance users if new workers are added or removed during a test run.", |
@tyge68, the re-balancing also needs to be implemented when a worker goes missing: Line 834 in bb77344
Also, I'll have to revisit my code, because according to this: Lines 873 to 875 in a278fb3
I already implemented the rebalance when a worker joins. Apparently, it doesn't work, otherwise @tyge68 would have not reported the issue. I'll try to look into this soon. |
locust/test/test_runners.py
Outdated
@@ -717,7 +717,7 @@ def addWorker(): | |||
def checkRebalancedTrue(): |
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.
In Python, snake_case
is preferred. There's some old library such as unittest
that uses camelCase
(i.e. self.assertTrue
), but this is only because the standard library needs to keep backward compatibility.
# This is the 1st commit message: locustio#1884 User distribution should happen when new workers comes in # This is the commit message locustio#2: locustio#1884 reformatting # This is the commit message locustio#3: locustio#1884 Make rebalance interval configurable # This is the commit message locustio#4: locustio#1884 Adding integration test for rebalanced # This is the commit message locustio#5: locustio#1884 revert change # This is the commit message locustio#6: locustio#1886 Simplify solution # This is the commit message locustio#7: locustio#1886 adding missing dependency # This is the commit message locustio#8: locustio#1884 Adding back enable rebalancing option # This is the commit message locustio#9: locustio#1884 adding extra comment the test # This is the commit message locustio#10: locustio#1884 renaming as suggested # This is the commit message locustio#11: locustio#1884 update help description # This is the commit message locustio#12: locustio#1884 handling of missing workers to rebalance
9e888fd
to
2b09b79
Compare
@mboutet I have applied the last suggested changes regarding the snake_case, and cleanup the commit history. |
LGTM, except for the remaining camelCase method (checkRebalancedTrue) in the test |
@cyberw indeed, fixed casing issue :) |
Just waiting for any comments from @mboutet ... |
Sorry for not getting back sooner. The changes and the test look good. I haven't tested the branch locally though. |
Thanks @tyge68 |
Thanks! I'll trust the tests to report any errors (and the poor sods running latest master/prerelease version :) |
I'm one of them 😜 |
To be checked how to test such code change.
cc @cyberw @mboutet