You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a test scenario where the custom load shape will generate random number of new users at each tick, and each user will stop itself after receiving the response of a HTTP GET request.
We observed that if we use distributed load generation by setting --process parameter while starting locust, sometimes when users are stopped between two ticks, the get_current_user_count() method is not able to to return the correct user number, some stopped users still counts in get_current_user_count() in subsequent ticks. This issue does not occur in local runner (w/o setting --process).
See below logs:
[2024-09-18 16:35:56,625] host/DEBUG/test_load_shape: Current users: 4, New users: 0, Target users: 4
[2024-09-18 16:35:57,075] host/DEBUG/urllib3.connectionpool: http://host-ip:80 "GET /sleep/5 HTTP/11" 200 None
[2024-09-18 16:35:57,075] host/INFO/root: Stopping current user: <test_load_shape.MyUser object at 0x7f362c904310>
[2024-09-18 16:35:57,626] host/DEBUG/test_load_shape: Current users: 4, New users: 0, Target users: 4
[2024-09-18 16:35:58,628] host/DEBUG/test_load_shape: Current users: 4, New users: 2, Target users: 6
One user has received the response and stopped, the correct user number should be 3, but in the subsequent ticks, the current user returned from get_current_user_count() still remains at 4.
Hey,
It seems that the issue is related to the get_current_user_count() method not returning the correct number of active users when running Locust with distributed processes. The problem occurs when users stop between ticks, and the count doesn't get updated across processes correctly, leading to stale data.
One potential fix could involve synchronizing the user count across all processes before the tick() method uses it for decision-making. By ensuring that the user count is up-to-date across distributed workers, we can avoid counting stopped users in subsequent ticks. Additionally, making sure that users are cleanly stopped and immediately removed from the active count will help prevent race conditions.
I am interested in contributing to this issue and I'd appreciate any thoughts or feedback on this approach!
Prerequisites
Description
I have a test scenario where the custom load shape will generate random number of new users at each tick, and each user will stop itself after receiving the response of a HTTP GET request.
We observed that if we use distributed load generation by setting
--process
parameter while starting locust, sometimes when users are stopped between two ticks, theget_current_user_count()
method is not able to to return the correct user number, some stopped users still counts inget_current_user_count()
in subsequent ticks. This issue does not occur in local runner (w/o setting--process
).See below logs:
One user has received the response and stopped, the correct user number should be 3, but in the subsequent ticks, the current user returned from
get_current_user_count()
still remains at 4.Command line
locust -f test_load_shape.py -H http:///sleep/5 --headless --process 1 --loglevel DEBUG -s 120
Locustfile contents
Python version
3.11.9
Locust version
2.31.4
Operating system
Ubuntu 22.04.1
The text was updated successfully, but these errors were encountered: