locust压测入门
一、安装 pip install locust 了解locust相关命令:locust --help 二、获取当前CPU核心数 (后面需要根据核心数起进程) pip3 install psutil ``` import pustil print(pustil.cpu_count(False)) ``` 三、准备压测脚本(lc.py): ``` # 这是一个压测的临时脚本. import requests import json import uuid import time from locust import between, task, constant from locust.contrib.fasthttp import FastHttpUser import random # from utils.data import data data = { "header": [["query"]], "data": [ {"query": "后海大鲨鱼"}, {"query": "这个衣服宽松不"}, {"query": "包装好点"}, ], } class WebsiteUser(FastHttpUser): wait_time = between(1, 1) host = "http://nta-api-ks.leyanbot.com" def body(self):