Let’s derive the 53 MB broker memory estimate from first principles:
TCP connections (200 machines): \[M_{conn} = 200 \times 8\text{KB} = 1.6\text{ MB}\] (per-connection buffer: 4 KB send + 4 KB receive)
Topics and subscriptions:
- Topics: \(200 \times 3 = 600\) unique topics @ 100 bytes each = 0.06 MB
- Subscriptions: \(600 \times 6 = 3{,}600\) @ 50 bytes each = 0.18 MB
Message buffers (the dominant factor): - Outbound rate: 3,600 msg/sec - Average message: 100 bytes (header + payload) - If slowest subscriber lags 5 seconds: \(3{,}600 \times 5 = 18{,}000\) queued messages \[M_{queue} = 18{,}000 \times 100 = 1.8\text{ MB}\]
Per-subscriber queue (6 subscribers, QoS 1): - Each needs in-flight tracking: 10 messages × 200 bytes = 2 KB \[M_{tracking} = 6 \times 2\text{KB} = 12\text{KB} = 0.012\text{ MB}\]
Topic tree (routing structure): - Binary tree nodes: ~600 topics × 64 bytes/node = 0.038 MB
Total memory: \[M_{total} = 1.6 + 0.06 + 0.18 + 1.8 + 0.012 + 0.038 = 3.69\text{ MB}\]
Discrepancy from 53 MB claim: The 53 MB likely includes OS overhead (TCP stack, kernel buffers), broker process memory, and safety margin (4×). Core MQTT state is ~4 MB.