Locust的分布式测试

Locust的分布式测试

1、什么情况下需要使用分布式测试
如果单台计算机不足以模拟所需的用户数量,那么Locust将支持运行分布在多台计算机上的负载测试。

2、设置的方法
为此,您可以使用该–master标志在主模式下启动Locust的一个实例。这是将运行Locust的Web界面的实例,您可以在其中开始测试并查看实时统计信息。主节点本身不会模拟任何用户。取而代之的是,您必须使用该–slave标志以及 --master-host(指定主节点的IP /主机名)来启动一个或(很可能是)多个从蝗虫从节点。

常见的设置是在一台机器上运行一个主机,然后在从属机器上每个处理器内核运行一个从属实例。

特别说明:在运行Locust分布式系统时,主计算机和每个从属计算机都必须具有蝗虫测试脚本的副本。
建议:建议您启动的模拟用户数量要大于 运行Locust分布式系统时的数量。。
官方说明:
It’s recommended that you start a number of simulated users that are greater than number of locust classes * number of slaves when running Locust distributed.

Otherwise - due to the current implementation - you might end up with a distribution of the Locust classes that doesn’t correspond to the Locust classes’ weight attribute. And if the hatch rate is lower than the number of slave nodes, the hatching would occur in “bursts” where all slave node would hatch a single user and then sleep for multiple seconds, hatch another user, sleep and repeat.

3、实例:
在我们自己主机(即master机)下使用命令:

locust -f my_locustfile.py --master

单机开机slave,无需指定master机器,默认为本机:

locust -f locustfile.py --slave

多机开启slave,需要指定master机器的host:(192.168.0.14用master机的IP 替换):

locust -f my_locustfile.py --slave --master-host=192.168.0.14

4、选项说明
–master
将蝗虫设置为主模式。Web界面将在此节点上运行。

–slave
将蝗虫设置为从属模式。

–master-host=X.X.X.X
(可选)与–slave设置主节点的主机名/ IP 一起使用(默认为127.0.0.1)

–master-port=5557
(可选)与–slave一起设置主节点的端口号(默认为5557)。请注意,蝗虫将使用指定的端口以及端口号+1。因此,如果使用5557,则蝗虫将同时使用端口5557和5558。

–master-bind-host=X.X.X.X
可选与一起使用–master。确定主节点将绑定到的网络接口。默认为*(所有可用接口)

–master-bind-port=5557
可选与一起使用–master。确定主节点将侦听的网络端口。默认值为5557。请注意,蝗虫将使用指定的端口以及端口号+1。因此,如果使用5557,则蝗虫将同时使用端口5557和5558。

–expect-slaves=X
使用启动主节点时使用–no-web。然后,主节点将等待,直到X个从节点已连接,然后才能开始测试。

发布了44 篇原创文章 · 获赞 1 · 访问量 1476

猜你喜欢

转载自blog.csdn.net/cc_park/article/details/103616114
今日推荐