feat(go): batch redis fast writer projections

This commit is contained in:
lingniu
2026-07-03 19:45:00 +08:00
parent 81e050ec1c
commit 3a0d9bd840
7 changed files with 173 additions and 10 deletions

View File

@@ -20,6 +20,8 @@ Go 版本车辆数据接入链路已经作为生产主链路运行在 ECS `115.2
5. 解析字段只投影一次,避免 TDengine/Redis/MySQL 各自重复 flatten。
6. 新长期目标:朝 10W 车辆生产稳定运行优化,容量基线见 `docs/ops/100k-capacity-baseline.md`
2026-07-03 之后,`nats-fast-writer` 的快速路径是 TDengine 批写 + Redis 批量 pipeline一个 NATS fetch batch 先批量写 TDengine再用 `FastUpdateBatch` 把实时 KV、在线 TTL、last_seen 和协议索引合并到一次 Redis pipeline最后逐条 ack NATS。
## 服务和端口
ECS`115.29.187.205`
@@ -431,7 +433,7 @@ vehicle_fast_writer_stage_duration_ms_histogram_sum{subject,stage,status}
`stage` 取值包括 `tdengine``redis``ack`,分别对应快速写 TDengine raw/location、Redis realtime 投影、NATS ack。带帧率压测时如果某个 stage 的 p99 持续上升,可以直接定位 fast path 是存储瓶颈还是 ack/网络瓶颈。
2026-07-03 后续优化:`nats-fast-writer` 已从“Fetch batch 后逐条写 TDengine”改为“Fetch batch 后先调用 `history.Writer.AppendAllBatch` 批量写 TDengine逐条更新 Redis 和 ack”。这样可以减少 TDengine round tripRedis/ack 仍按单条执行,避免某条实时投影失败时误 ack。
2026-07-03 后续优化:`nats-fast-writer` 已从“Fetch batch 后逐条写 TDengine/Redis”改为“Fetch batch 后先调用 `history.Writer.AppendAllBatch` 批量写 TDengine调用 `realtime.Repository.FastUpdateBatch` 用一次 Redis pipeline 写实时 KV/在线状态/索引,最后逐条 ack NATS”。这样可以同时减少 TDengine 和 Redis round tripack 仍按单条执行,避免存储失败时误 ack。
2026-07-03 后续优化:`nats-fast-writer` 的 TDengine SQL 连接池已从固定 `1` 改为可配置: