1.安裝
pip install locustio
安裝成功后,提示:Successfully installed Jinja2-2.9.6 MarkupSafe-1.0 Werkzeug-0.12.2 click-6.7 flask-0.12.2 gevent-1.1.1 greenlet-0.4.12 itsdangerous-0.24 locustio-0.7.5 msgpack-python-0.4.8
2.Installing ZeroMQ
運(yùn)行Locust分布在多個(gè)進(jìn)程/機(jī)器互躬,安裝pyzmq:pip install pyzmq
3.quickstart
新建baidu_load.py:
from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
? ? @task(1)
? ? def baidu(self):
? ? ? ? self.client.get("/")
class WebsiteUser(HttpLocust):
? ? """docstring for WebsiteUser"""
? ? task_set = UserBehavior
? ? min_wait = 5000
? ? max_wait = 9000
4.運(yùn)行l(wèi)ocust
locust -f baidu_load.py --host=http://baidu.com
5.進(jìn)入localhost:8089
設(shè)置虛擬用戶和訪問(wèn)速度: