目录
前言
- 一旦单台计算机不足以模拟所需的用户数量,Locust就会支持运行分布在多台计算机上的负载测试。
- 为此,您可以使用该
--master标志在主模式下启动Locust的一个实例,使用该--worker标志以及--master-host(指定主节点的IP /主机名)来启动一个或-可能是多个工人Locust节点。
脚本
# -*- coding: utf-8 -*-
# @Time : 2021/4/10
# @Author : 大海
import os
from locust import HttpUser, task, constant
class MyUser(HttpUser):
wait_time = constant(1)
@task
def my_task(self):
self.client.get('/')
if __name__ == '__main__':
file_path = os.path.abspath(__file__)
os.system(f'locust -f {file_path} --master --web-host=127.0.0.1')
启动
- 启动master:locust&nbs

本文介绍如何使用Locust进行分布式负载测试。通过设置Master和Worker节点,可以模拟大量用户并发访问,实现对系统的性能评估。文章包含启动配置、脚本示例及关键参数说明。
最低0.47元/天 解锁文章
1258

被折叠的 条评论
为什么被折叠?



