01
高流量訊息處理系統重構High-Throughput Message Processing System Refactor
同一測試環境下,吞吐量由 50–100 TPS 提升至 1000+ TPSThroughput increased from 50–100 TPS to over 1000+ TPS in the same test environment
- 將多筆資料轉成 JSON 格式,一次性傳入資料庫並以 Stored Procedure 處理,資料庫往返由 N 次降為 1 次,大幅降低處理延遲
- 將參照資料存放於 Redis,避免大量讀取資料庫;Redis 異常時自動降級至 MemoryCache 或資料庫,兼顧效能與可用性
- 以多個 consumer 並行消費 RabbitMQ,依實測調校 prefetch 與 consumer 數量,搭配手動 Ack/Nack 與自動重連,在拉高吞吐量的同時確保訊息不遺失
- 入口過濾訊息,減少不必要的處理
- 以訊息 Guid 串連各階段耗時 Log 並集中於 Graylog,快速定位延遲發生在哪一段
- 同一測試環境下,吞吐量由 50–100 TPS 提升至 1000+ TPS
- Batched multiple records into a single JSON payload and processed them in one round trip via a stored procedure, cutting database round trips from N to 1 and significantly reducing processing latency
- Cached reference data in Redis to avoid heavy database reads; falls back automatically to an in-memory cache or the database when Redis is unavailable, balancing performance and availability
- Consumed RabbitMQ with multiple parallel consumers, tuning prefetch count and consumer count based on load testing, with manual Ack/Nack and automatic reconnection to raise throughput while guaranteeing no message loss
- Filtered messages at the entry point to reduce unnecessary processing
- Correlated per-stage timing logs by message GUID and centralized them in Graylog to quickly pinpoint where latency occurs
- Throughput increased from 50–100 TPS to over 1000+ TPS in the same test environment
- 外部來源External sources
- 接收服務Receiving service
- 內部緩衝 MQInternal buffer MQ
- 轉發服務Forwarding service
- 業務分類 MQBusiness-classified MQ
- 多組 consumerMultiple consumer groups
- 資料庫Database批次預存程序Batch stored procedure
- Redis參照資料Reference data