-
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
Support for completely custom load pattern / shape #1432
Comments
Sounds nice, and I definitely see the need for it. A PR would be welcome :) |
I agree that this is a feature that would be really nice to have. I've been thinking about this quite a bit, but at the moment I don't have the time to start testing things out / implementing stuff, though here are some thoughts: I think we should start with an even lower level API for a test plan. Perhaps a class that has one or more methods that gets called every second (or similar) with the current run time in seconds, and which can return the current user count and spawn rate, as well as a way for it to end the test. class CustomPlan(TestPlan):
def tick(run_time, current_user_count, current_spawn_rate):
if run_time < 600:
return UserCount(600, 100)
elif run_time < 3600:
return UserCount(2000, 100)
elif run_time < 3900:
return UserCount(5000, 50)
elif run_time < 4500:
return UserCount(1000, 100)
else:
return StopPlan() This API could then support implementing an API on top of it, similar to the one you suggested @max-rocket-internet Please note that the above code was written on the fly from the top of my head, and there might be issues with it that I haven't thought about. For example, we probably want to support specifying the exact number of users for specific User classes. Also, I'm imagining it as something that runs within the master node, and I'm not sure if there's any limitations that comes from that. |
I would be keen but have holiday coming up. Happy to look at it afterwards.
Sounds good.
Also good.
I think that's correct. Any idea where this would go? Something similar to stepload_worker? |
Unfortunately the stepload implementation isn't very good and I think it should be removed and re-implemented on top of the test plan API. |
@heyman or @cyberw could you just give me a rough pointer of where this would go in the code base? Something in spawn_users? I will start working on it next week. |
@heyman where would this method get called? I can't work out a good place to put this part. |
In the end, it is Runner.spawn_users().hatch() that needs to know what to do, so maybe it can be called from there? |
|
Ok, then I dont have any bright ideas. Tbh, I think the code around spawning users is a little convoluted and could probably do with some refactoring (I havent spent a lot of time looking in to it though) |
The problem I see is that we need to run a loop to control the |
Maybe I could create
|
would it not be possible to use the same way for ”non-custom” runs? I’d prefer to only maintain one ramping feature :) Also, I think everything should be done in the greenlet if possible (do 1 & 2 in the greenlet) Other than that it sounds ok! |
Correct me if I'm wrong but the current process is like this:
Currently we are editing a running test via the locust API to change the Anyway, this is my current very rough work: https://github.com/locustio/locust/compare/master...max-rocket-internet:loadtest_shaper?expand=1 Any feedback welcome 🙂 I think potentially we could replace the "step load" feature with this approach. This could tidy up a lot of the code. |
Looks nice. We'll need a couple really of good unit tests for this, including cases
A few opinions:
|
Tbh, I think we could skip the "high level"/k6-like api, at least as a first step. Being able to specify the shape with a dict is only marginally more user friendly than having a function, and many users might not understand the the flexibility you can actually have if you can't see the code (if you want to do high/low load for X amount of time for instance) |
For sure.
OK, sure thing.
Can do but this is needless complexity, no? You can already import things from other files in python.
Agreed 👍 |
I just like the idea of having the load profile "orthogonal" to the User definition. Sure, you could specify the shape file with -f and have multiple shape files import the same "actual" locustfile (with User definitions), but it feels a bit upside down and ties the load profile tightly to a locustfile. Maybe not super important though... |
Please view: #1505 |
Describe the solution you'd like
To be able to programmatically control the user and hatch rate over a period of time. This would allow us to scale up and down and generate spikes which allows more accurate representation of real world load.
We can generate this easily:
But not this:
And not this either:
Describe alternatives you've considered
I tried something quite hacky but it's not good enough:
Also I know we could implement this outside of locust and call the locust API but it's not ideal.
Additional context
k6 has something called stages that looks great:
It would be great to see something like this in locust. Perhaps it could look like this:
The text was updated successfully, but these errors were encountered: