1. 安装locust

pip3 install locust

 

2. 写python脚本

from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
    def on_start(self):
        pass
    def on_stop(self):
        pass
    @task(1)
    def index(self):
        self.client.get("/")
class User(HttpLocust):  # 用户类
    task_set = UserBehavior
    min_wait = 3000  # 毫秒
    max_wait = 6000  # 毫秒

3. 命令行,执行脚本,启动界面, host为需要测试的链接

locust -f test.py --host=http://xx.xxx.com/wap

 

4. 在浏览器执行http://localhost:8089/,则界面如下所示:

 

第一个:Number of total users to simulate: 通过多个线程模拟多个用户

第二个:Hatch rate: 每秒增加多少用户 

假设设置为10,则每秒增加10个用户

关于第二个值对结果的影响,实验过后稍后补充

   压力测试-locust讲解

 

 

 

 

5. 执行后结果:

其中RPS 是每秒执行的请求数量,相当于QPS;

Requests表示请求的数量;

顶部的Statistics是一个聚合的结果;Charts是一些图表;Download Data 是可以下载一些数据;

 

压力测试-locust讲解

 

 

  

 

 

参考文献:http://www.cocoachina.com/cms/wap.php?action=article&id=34761#cocoachina11

相关文章:

  • 2022-02-15
  • 2022-01-18
  • 2021-11-13
  • 2022-01-29
  • 2021-07-21
  • 2021-10-19
猜你喜欢
  • 2021-08-23
  • 2022-01-01
  • 2021-12-11
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2021-10-30
相关资源
相似解决方案