如何将不同的用户分配给蝗虫工人的不同“用户”实例?
我正在使用蝗虫进行性能测试,我想使用分布式负载功能。但是,在某种程度上,每个用户仅在一个会话中持续存在,因此每个用户实例应具有不同的登录用户。
在我的蝗虫文件的单个进程版本中,我使用一个全局集合到pop
每个user
实例的随机用户:
idle_users = {id for id in range(1, 65535)}
class MyUser(FastHttpUser):
__user: int = None
def get_one_user(self):
global idle_users
self.__user = idle_users.pop()
def on_stop(self):
global idle_users
idle_users.add(self.__user)
我的问题是,当进入分布式版本时get_one_user
,我如何访问全局idle_users
设置,该设置位于一台计算机上的主实例上,从myuser
在worker实例上产生那在另一台机器上吗?
请注意,我已经阅读了有关distribution-loading-loading 的文档,但是@events.test_start
如果我希望在节点上的用户动态更改用户,那么Init似乎还为时过早。
更新:2022-05-24
关于用户的工作方式:myuser
s登录,通过调用on_start
和通过on_stop
登录。登录时,用户将从全局集合中随机获取。注销时,用户将被释放到全局集合,以便可以再次分发。也就是说,myuser
实例中的用户以及剩余的IDLE_USERS
在蜂拥而至时应动态更改。
I'm using Locust for performance testing, and I want to use the distributed load feature. However, there is some bound condition that each user persists for only one session so each user instance should have a different logged-in user.
In my single process version of the locust file, I use a global set to pop
a random user for each User
instance:
idle_users = {id for id in range(1, 65535)}
class MyUser(FastHttpUser):
__user: int = None
def get_one_user(self):
global idle_users
self.__user = idle_users.pop()
def on_stop(self):
global idle_users
idle_users.add(self.__user)
My question is, When coming into a distributed version of get_one_user
, how can I access the global idle_users
set, which is on the master instance on one machine, from a MyUser
spawning on a worker instance that is on another machine?
note that I've read the docs about the distributed-loading, but @events.test_start
seems too early to init if I want the users on a node dynamically changes.
updated: 2022-05-24
About how the users work: MyUser
s login by calling on_start
and logout by on_stop
. When logging in, a user is randomly fetched from the global set. When logout, the user is released to the global set so that it could be distributed again. That is, the users in MyUser
instances and in remaining idle_users
should dynamically change when swarming.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论