【问题标题】:how to stop locust when specific number of users are spawned with -i command line option?当使用 -i 命令行选项生成特定数量的用户时如何停止蝗虫?
【发布时间】:2021-08-08 19:00:59
【问题描述】:
from locust import SequentialTaskSet, HttpUser, constant, task
import locust_plugins

class MySeqTask(SequentialTaskSet):
    
    @task
    def get_status(self):
        self.client.get("/200")
        print("Status of 200")

    @task
    def get_100_status(self):
        self.client.get("/100")
        print("Status of 100")

class MyLoadTest(HttpUser):

    host = "https://http.cat"
    tasks = [MySeqTask]
    wait_time = constant(1)

【问题讨论】:

    标签: locust


    【解决方案1】:

    locust-plugins 命令行选项的示例可以在这里找到:

    https://github.com/SvenskaSpel/locust-plugins/blob/master/examples/cmd_line_examples.sh

    locust -u 5 -t 60 --headless -i 10
    # Stop locust after 10 task iterations (this is an upper bound, so you can be sure no more than 10 of iterations will be done)
    # Note that in a distributed run the parameter needs to be set on the workers, it is (currently) not distributed from master to worker.
    

    您将以与正常相同的方式运行您的 locust 文件,但将 -i 添加到您运行的每个工人。在我看来,因为它是每个工人,你需要预先计算你希望每个工人运行多少。因此,如果您有 10 个工作人员,并且您想在总共 10000 次任务迭代后停止,您可能会对每个工作人员执行-i 1000

    【讨论】:

      猜你喜欢
      • 2014-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多