参考网址:https://docs.locust.io/en/latest/running-locust-distributed.html
简介
Locust是一款易于使用的分布式用户负载测试工具。它用于对网站(或其他系统)进行负载测试,并确定系统可以处理多少并发用户。
特点
- 使用python编写测试脚本
- 支持模拟数十万用户
- 基于web的操作界面
- 可以测试任何网站
安装
系统centos 7
pip install locustio
示例代码
from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
def on_start(self):
""" on_start is called when a Locust start before any task is scheduled """
self.login()
def on_stop(self):
""" on_stop is called when the TaskSet is stopping """
self.logout()
def login(self):
self.client.post("/login", {"username":"ellen_key", "password":"education&