locust是使用python的一种测试工具;注意python3最好在3.8以上较好。

首先要有python3的安装。

》pip3 install locust --timeout=12000

※ 有时安装过程较长,可添加 --timeout设置时间变长。中途会断,需要多次尝试。如果ssl没权限,则需要查看python安装ssl部分。

pip3 install locust --timeout=12000  -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

官网地址:https://docs.locust.io/en/stable/installation.html

                 

 

※ 异常:gcc: error trying to exec 'cc1plus': execvp: No such file or directory

缺少c++包,或gcc和g++版本不一致。可查看

>gcc -v

> yum install gcc-c++

 

参照官网示例:https://docs.locust.io/en/stable/quickstart.html

但是页面的8089默认使用的localhost,而非127.0.0.1,只能用localhost访问。对于测试机发布在页面查看,在启动参数添加:

》 --web-host=172.20.48.72 --web-port=8076

因locust默认会占据单个cpu,因此要在多核上使用,则需要启用master和工作worker

》nohup locust -f mytest.py  --web-host=172.122.33.44 --web-port=8076 --master &

》nohup locust -f mytest.py  --web-host=172.122.33.44 --web-port=8076 --worker &(根据需要可多添加)

 

posted on 2023-02-01 17:10  zhaoqiang1980  阅读(41)  评论(0编辑  收藏  举报