ThingsBoard压力测试工具performance-tests使用方法

linux | 2021-11-19 16:20:39

performance-tests是官方能够模拟从不同设备同时发布的大量 MQTT 消息对 ThingsBoard 服务器进行压力测试的工具。官方文档:https://github.com/thingsboard/performance-tests

1.新建配置文件

touch env

vi env

REST_URL=http://1.35.2.83:88
# IP_ADDRESS_OF_TB_INSTANCE is your local IP address if you run ThingsBoard on your dev machine in docker
# Port should be modified as well if needed
REST_USERNAME=tenant@annazn.com
REST_PASSWORD=tenant

MQTT_HOST=1.35.2.83
# IP_ADDRESS_OF_TB_INSTANCE is your local IP address if you run ThingsBoard on your dev machine in docker
MQTT_PORT=1883

MQTT_SSL_ENABLED=false
MQTT_SSL_KEY_STORE=mqttclient.jks
MQTT_SSL_KEY_STORE_PASSWORD=

# Test API to use - device or gateway. In case device data is send directly to devices, in case gateway - over MQTT gateway API
TEST_API=gateway

# Device API to use - MQTT or HTTP. HTTP applicable only in case TEST_API=device
DEVICE_API=MQTT

DEVICE_START_IDX=0
DEVICE_END_IDX=50
DEVICE_CREATE_ON_START=true
DEVICE_DELETE_ON_COMPLETE=false

GATEWAY_START_IDX=0
GATEWAY_END_IDX=1
GATEWAY_CREATE_ON_START=true
GATEWAY_DELETE_ON_COMPLETE=true

WARMUP_ENABLED=false

# Type of the payload to send: DEFAULT, SMART_TRACKER, SMART_METER
# RANDOM - TODO: add description
# SMART_TRACKER - sample payload: {"latitude": 42.222222, "longitude": 73.333333, "speed": 55.5, "fuel": 92, "batteryLevel": 81}
# SMART_METER - sample payload: {"pulseCounter": 1234567, "leakage": false, "batteryLevel": 81}
TEST_PAYLOAD_TYPE=SMART_TRACKER

TEST_ENABLED=true

# true - send data to devices by device ids, false - select random devices from the list
TEST_SEQUENTIAL=true

MESSAGES_PER_SECOND=50000
DURATION_IN_SECONDS=2

UPDATE_ROOT_RULE_CHAIN=false
REVERT_ROOT_RULE_CHAIN=false
RULE_CHAIN_NAME=root_rule_chain_ce.json

需要修改tb的地址用户密码还有mqtt的服务地址,其他的根据需要修改网关和设备的数量

2.启动docker 服务进行测试

docker stop tb-perf-test
docker rm tb-perf-test

docker run -it --env-file env -e TZ="Asia/Shanghai" -v /etc/localtime:/etc/localtime:ro --name tb-perf-test thingsboard/tb-ce-performance-test:3.0.0

然后就会打印出测试的详情,包括 推送的数据批次 开始时间和完成时间,但是这个时间,只是 推送到mqtt,mqtt响应的时间,不包括规则链处理入库的时间,这个时间可能更长

登录后即可回复 登录 | 注册
    
关注编程学问公众号