English Abstract — Part 3 of 3. Operations: three-layer rate limiting (EMQX → Rule Engine → App), content-based dedup, anomaly detection. Edge resilience: exponential backoff + jitter, offline buffering (RAM/SQLite/MQTT Session Expiry). Server HA with RPO/RTO per component. OpenTelemetry end-to-end tracing. Multi-region DR (Active-Passive). Team onboarding risk and phased rollout.
flowchart LR
D[Faulty Device] -->|10 msg/s limit| E[EMQX]
E -->|SQL filter| T[TimescaleDB]
T -->|circuit breaker| A[FastAPI]
E -->|exceed 10x| X1[Disconnect]
層
限制
超限動作
說明
EMQX
10 msg/s, 50 KB/s
Throttle → disconnect
第一道防線,per-client
Rule Engine
SQL filter + dedup
丟棄不符條件
基本過濾,無需代碼
FastAPI
Per-tenant rate limit
Alert + reject
業務邏輯層防護
Dedup 策略
層
策略
MQTT Broker
Packet ID tracking
Rule Engine
SQL WHERE + timestamp 比對
Application
(device_id, timestamp, hash)
Database
ON CONFLICT DO NOTHING
異常偵測
類型
偵測
處理
超頻上報
Rate > 10x
Broker throttle
範圍異常
超 physical range
丟棄 + 告警
時序異常
偏差 > 5min
標記 suspect
靜默設備
> 3x 正常間隔
LWT → offline 告警
Edge Resilience
Reconnect + Offline Buffer
stateDiagram-v2
[*] --> Connected
Connected --> Disconnected: Network down
Disconnected --> Retry1s: Retry 1s
Retry1s --> Connected: OK
Retry1s --> Retry2s: Fail
Retry2s --> RetryMax: Backoff + jitter
RetryMax --> Connected: OK
note right of Disconnected: Write to local buffer
note right of Connected: Drain buffer on reconnect
flowchart TD
E[EMQX] -->|metrics| P[Prometheus]
A[FastAPI] -->|traces| OT[OpenTelemetry]
BF[BFF] -->|traces| OT
T[TimescaleDB] -->|metrics| P
OT --> J[Jaeger]
OT --> P
OT --> L[Loki]
P --> G[Grafana]
J --> G
L --> G