2

Say I have 10k users in a locust swarm. I want to have 2000 of them running the tasks from Task Set A, 2000 of them running the tasks from Task Set B, and 6000 of them running the tasks from Task Set C, where each task set has its own frequency.

Is there a way to configure this? I tried setting self.tasks at runtime, but it doesn't seem to be working.

fields
  • 4,433
  • 4
  • 27
  • 32

3 Answers3

2

You can assign weights to your locust class. Just define 3 different Locust classes (one for each type of user) each using a different task set, and with weights set to 2, 2 and 6 respectively.

Cigogne Eveillée
  • 2,178
  • 22
  • 36
1

I think what you're looking for is closer to weighting user behaviors. See http://docs.locust.io/en/latest/writing-a-locustfile.html#the-weight-attribute

The gist is that you can define and weight different types of users, then run your locust command with all of the users defined as arguments.

Pasting from link for posterity:

class WebUserLocust(Locust):
    weight = 3
    ....

class MobileUserLocust(Locust):
    weight = 1
    ....

then

locust WebUserLocust MobileUserLocust
Grey Vugrin
  • 455
  • 5
  • 12
0

You can give appropriate weight to handle this problem. @task(2) runs twice of @task(1). See below for your case:

@task(2)
def A(self):
    a()

@task(2)
def B(self):
    b()

@task(6)
def C(self):
    c()
Mesut GUNES
  • 7,089
  • 2
  • 32
  • 49
  • That won't really do what I want. I want to specify different frequencies for each class of users, which I think requires using different task sets which can each have their own min and max timings. – fields Feb 11 '16 at 14:51
  • with frequencies do you mean RPS? – Mesut GUNES Feb 11 '16 at 14:56
  • yes, so group a will do something every three seconds, and group b will do something every 10 seconds, and so forth. – fields Feb 11 '16 at 17:41
  • @fields Playing with rps iş not that easy and one of locust core developer says it is not designed for that instead use weight for simulating real user behaviour. See this http://stackoverflow.com/a/27716019/2568849 – Mesut GUNES Feb 11 '16 at 17:45