性能测试工具 使用 locust 进行压测的时候,发现并发用户数一直达不到设置的标准

ghost · 2018年11月07日 · 最后由 Grandlulu 回复于 2018年12月07日 · 4039 次阅读

问题 RT。请大家帮忙看下,感激不尽!🙏 🙏 🙏

** 想对环境进行下压测,看下并发数和相关吞吐量的情况。中间遇到一个问题:
用 locust 设置用户为 50 的时候,发现执行 locust,并发数只能达到 31.
将并发数设置为 100 时,最后并发数是 81,总是有 19 个用户没法执行。

不知道是为啥.**

这个是登录的账号,相关的账号信息如下,包含用户类型,用户名,密码

登录的代码如下

def login(self):
    username,password = get_customer_account()
    login='/passport/login'
    params={'logintype':'PASSWORD','username':username,'password':password}
    r=self.client.post(base_url+login,data=params)
    print('username',username)
    print(r.status_code)
    print("登录成功")

上面的 get_customer_account() 是下面这个读取文件的模块提供的

demo_environment = 'demo_username.csv'
master_environment = 'master_username.csv'
test_environment = 'test_username.csv'

#获取登录文件,然后拿到登录账号进行登录*************************************************************
path_parent=os.path.abspath(os.path.dirname(os.path.dirname(__file__)))  #获取父目录
path = path_parent+'/csv_data/' + demo_environment

with open(path) as file:
    customer_queue=queue.Queue()
    supplier_queue=queue.Queue()
    manager_queue=queue.Queue()

    for line in file:
        if 'account_type' in line:
            print('跳过登录表首行列名')
        elif 'customer' in line:
            account=line.strip().split(',')[1]
            password=line.strip().split(',')[2]
            customer_queue.put([account,password])
        elif 'supplier' in line:
            account=line.strip().split(',')[1]
            password=line.strip().split(',')[2]
            supplier_queue.put([account,password])
        elif 'manager' in line:
            account=line.strip().split(',')[1]
            password=line.strip().split(',')[2]
            manager_queue.put([account,password])


#每次获取队列元素的时候,同时进行写入
def get_customer_account():
    account,password=customer_queue.get()
    customer_queue.put([account,password])
    return account,password

共收到 8 条回复 时间 点赞

编辑,静候大佬解释

黑山老妖 回复

没有,一共有大概 30 个账号,其中 19 个是我本次测试需要登录的

服务器有顶号逻辑

a2021 回复

我们的 pc 端登录目前是支持多点登录的,虽然是同一个账号,暂时作查询操作还是互不影响的

信息有限,不好分析;先把 locust 更新到最新分支代码再测试看看,早期的版本图表统计会有些不稳定现象

在路上 回复

已经升级到最新的 0.9.0 了,还是不行

楼主能看看你的源码嘛,谢谢

个人估计:你的 30 个用和 80 个用户的 rts 全部在 18 左右,判断为本机达到了瓶颈,尝试 master slave 方式,压力机并发 人数应该能达到你的要求

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册