1、pip install locustio
2. Install pyzmq
If you intend to run Locust distributed across multiple processes/machines, we recommend you to also install pyzmq.
If you plan to run Locust distributed across multiple processes/machines, we recommend that you also install pyzmq.
Install via pip command. /> pip install pyzmq
3. The installation is successful, and the CMD type command is verified. /> locust --help
Create the first locustDemo:
# -*- coding: utf-8 -*-
from locust import HttpLocust, TaskSet, task #Classes that
define user behavior
class UserBehavior(TaskSet):
@task(1) #Define the weight of execution, the task of multiple requests determines the proportion of execution
def login(self):
self.client .get("/") #Define the path of the request
class WebsiteUser(HttpLocust): #Define
the requested host, the user behavior to be executed, the maximum and minimum waiting time
host = "http://baidu.com"
task_set = UserBehavior
min_wait = 3000
max_wait = 6000
Switch to the directory where the user behavior is located and execute the command:
locust -f /Users/dasouche/PycharmProjects/LearnPython/Locust.py #path to file
Open a browser to visit: http://127.0.0.1:8089
Number of users to simulate Set the number of users to simulate
Hatch rate (users spawned/second) The number of users spawned (launched) per second.
Click Start swarming to start running the performance test.