Locust-通过任务等待机制限制吞吐量

Locust任务等待的几种方式:

constant(2)

任务执行完毕等待2秒开始下一任务

between(1,7)

任务执行完毕等待1-7秒(中间随机取值)开始下一任务

constant_pacing(6)

从任务启动开始计算时间,若任务耗时超过该时间,则任务结束后立即执行下一任务;若任务耗时不超过该时间,则等待达到该时间后执行下一任务。

constant_throughput(2)

constant_throughput(2)同constant_pacing(1/2),
表示每秒最多执行2次。
def constant_throughput(task_runs_per_second):
    return constant_pacing(1 / task_runs_per_second)

测试下:
手写一个接口,RT=3s
Users = 60

constant(6) constant(3) constant(2)
TPS 60/6+3 60/3+3 60/2+3
constant_pacing(6) constant_pacing(3) constant_pacing(2)
TPS 60/3+3 60/3 60/3
posted @ 2023-05-25 17:13  扬帆去远航  阅读(197)  评论(0)    收藏  举报