规则引擎性能基准测试
概述
本文档提供 FluxMQ 2.1.0 版本规则引擎的性能基准测试数据,包括与前版本的对比分析,帮助用户了解性能改进和系统容量规划。
测试环境
硬件配置
- CPU: Intel Xeon E5-2686 v4 @ 2.3GHz (8 cores)
- 内存: 32GB DDR4
- 存储: SSD 500GB
- 网络: 万兆以太网
软件环境
- 操作系统: CentOS 7.8
- Java版本: OpenJDK 11.0.16
- JVM参数:
-Xms4g -Xmx8g -XX:+UseG1GC
- 数据库: MySQL 8.0.28, Redis 6.2.6
性能测试指标
核心性能指标
测试项目 | FluxMQ 2.0.18 | FluxMQ 2.1.0 | 性能提升 |
---|---|---|---|
规则执行吞吐量 | 50,000 msg/s | 70,000 msg/s | +40% |
单规则平均执行时间 | 120ms | 75ms | +37.5% |
内存使用(10万条规则) | 2.8GB | 2.1GB | -25% |
CPU使用率(峰值负载) | 85% | 68% | -20% |
并发规则数量 | 1,000 | 2,000 | +100% |
函数执行性能对比
函数类型 | 2.0.18 平均耗时 | 2.1.0 平均耗时 | 性能提升 |
---|---|---|---|
字符串处理 | 2.5ms | 1.2ms | +52% |
JSON解析 | 8.3ms | 4.1ms | +51% |
时间格式化 | 1.8ms | 0.9ms | +50% |
数据类型转换 | 1.2ms | 0.6ms | +50% |
加密哈希 | 5.4ms | 3.2ms | +41% |
详细测试结果
1. 吞吐量测试
测试场景
- 模拟 10,000 个并发 MQTT 客户端
- 每个客户端每秒发送 10 条消息
- 总消息吞吐量:100,000 msg/s
- 配置 100 个不同复杂度的规则
测试结果
简单规则性能(仅主题过滤):
SELECT * FROM "$EVENT.PUBLISH" WHERE topic = 'sensor/temperature'
版本 | 处理吞吐量 | 平均延迟 | 99分位延迟 |
---|---|---|---|
2.0.18 | 95,000 msg/s | 15ms | 45ms |
2.1.0 | 135,000 msg/s | 10ms | 28ms |
复杂规则性能(包含函数调用):
SELECT
uuid() as id,
json(payload) as data,
datetime(timestamp) as time,
md5(clientId) as hash
FROM "$EVENT.PUBLISH"
WHERE topic =~ 'sensor/+/data' AND payload.value > 30
版本 | 处理吞吐量 | 平均延迟 | 99分位延迟 |
---|---|---|---|
2.0.18 | 25,000 msg/s | 85ms | 180ms |
2.1.0 | 45,000 msg/s | 55ms | 120ms |
2. 内存使用效率测试
测试场景
- 创建不同数量的活跃规则
- 每个规则处理 1,000 msg/s
- 监控系统内存使用
测试结果
规则数量 | 2.0.18 内存使用 | 2.1.0 内存使用 | 内存节省 |
---|---|---|---|
100 | 680MB | 520MB | -23.5% |
500 | 1.8GB | 1.3GB | -27.8% |
1,000 | 2.8GB | 2.1GB | -25.0% |
2,000 | 4.5GB | 3.2GB | -28.9% |
3. 函 数库性能测试
新增函数性能基准
字符串处理函数:
SELECT
split(topic, '/') as parts,
substring(clientId, 0, 8) as prefix,
find(payload, 'error') as error_info
FROM "$EVENT.PUBLISH"
- 执行时间: 1.2ms (平均)
- 内存占用: 85KB (临时)
- CPU使用: 2.5%
时间处理函数:
SELECT
date(timestamp) as date_str,
datetime(timestamp) as datetime_str,
datetimeToTimestamp("2023-07-29 10:30:15") as ts
FROM "$EVENT.PUBLISH"
- 执行时间: 0.9ms (平均)
- 内存占用: 45KB (临时)
- CPU使用: 1.8%
加密函数:
SELECT
md5(payload) as payload_hash,
sha256(clientId) as client_hash,
uuid() as message_id
FROM "$EVENT.PUBLISH"
- 执行时间: 3.2ms (平均)
- 内存占用: 128KB (临时)
- CPU使用: 5.2%