Support for completely custom load pattern / shape
See original GitHub issueDescribe 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:
def traffic_spike(spike_after, spike_length, normal_wait_time):
def wait_time_func(self):
if not hasattr(self,"_traffic_spike_start"):
self._traffic_spike_start = time()
return normal_wait_time
else:
run_time = time() - self._traffic_spike_start
if run_time > (spike_after + spike_length) or run_time < spike_after:
return normal_wait_time
else:
return 0
return wait_time_func
class QuickstartUser(HttpUser):
wait_time = traffic_spike(600, 300, 1)
@task
def index_page(self):
self.client.get("/hello")
self.client.get("/world")
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:
export let options = {
stages: [
{ duration: '30s', target: 20 },
{ duration: '1m30s', target: 10 },
{ duration: '20s', target: 0 },
],
};
It would be great to see something like this in locust. Perhaps it could look like this:
from locust import User, TaskSet, between, LoadShape
class LoadWithSpike(LoadShape):
stages = [
{'duration': 3600, 'users' 1000, 'hatch': 5},
{'duration': 300, 'users' 5000, 'hatch': 50},
{'duration': 1800, 'users' 1000, 'hatch': -50}
]
class MyUser(HttpUser):
wait_time = between(1, 3)
@task(2)
def index(self):
self.client.get("/")
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (11 by maintainers)
Top Results From Across the Web
How to create custom patterns - Adobe Support
Learn how to create custom patterns using Adobe Illustrator. Enhance your presentation templates and make your slides pop!
Read more >3D Printing Supports – The Ultimate Guide - All3DP
Learn everything you need to know about 3D printing support structures. Tackle overhangs and bridges in your models with confidence!
Read more >How to Create a Custom Pattern in Photoshop - YouTube
In this tutorial I will show you how to create a custom pattern in Photoshop for your custom design.You can be very creative...
Read more >Filling Shapes with Colors and Patterns - SketchUp Help
Select a folder from the available options to choose one of LayOut's preset patterns. If you'd like to use a custom pattern, you...
Read more >How to Add Custom Pattern Fills in Silhouette Studio V4
Custom patterns can be anything from a photo to a digital background or seamless pattern. These can be used to fill shapes for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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…
Looks nice. We’ll need a couple really of good unit tests for this, including cases
A few opinions:
-f
arguments (as the effect of --shape would be to load another file which happens to include a shape class)