LocustIO:用户群

LocustIO: User swarm

我正在尝试 Locust。在这里,您可以使用指定孵化率内的模拟用户数量来聚集您的系统。

class UserBehavior(TaskSet):  
    def on_start(self):  
        self.login()  

    def login(self):
    payload = {"grant_type": "password",
              "username": self.my_user,
              "password": self.my_pw,
              ...
              }
            }
    headers = {'content-type': 'application/json'}
    response = self.client.post("/rest/v10/oauth2/token", data=json.dumps(payload), headers=headers, catch_response=True)
    self.token = response.json()['access_token']

    @task(1)
    def fetch_accounts(self):
        headers = {'oauth-token': self.token}
        response = self.client.get("/rest/v10/Accounts", headers=headers)   

使用的含义是什么:

  1. 单个 self.my_userself.my_pwNumber of users to simulate: 5

  2. 5 种不同的 self.my_userself.my_pwNumber of users to simulate: 1

  3. 5 个不同的 self.my_userself.my_pwNumber of users to simulate: 5

这三者中哪一个提供更可靠的负载测试报告输出?

简答

这取决于您的应用程序在负载下的行为。

长答案

通常,您希望模拟负载尽可能接近实际负载。在实际负载中,所有用户都不太可能使用相同的 username/password,单个用户也不太可能使用多个 username/password。所以我会说你的选项 3 可能是最现实的。但同样,这取决于您的应用程序。如果事实证明无论不同 username/password 组合的数量如何,您的应用程序的行为都相同,那么它可能根本无关紧要。