NATS notes/tips

Evaluating Jetstream as a store for Simple IoT

The nats-expGitHub - simpleiot/nats-exp repo has several experiments where we attempt to determine if we can use NATS Jetstream as a store for Simple IoT. So far, it looks promising.

Time-series metrics:

2024/01/03 14:20:10 NATS TSD experiment
2024/01/03 14:20:10 js.Publish insert rate for 10,000 points: 42028 pts/sec
2024/01/03 14:20:10 js.PublishAsync insert rate for 10,000 points: 412363 pts/sec
2024/01/03 14:20:10 nats.Publish insert rate for 10,000 points: 17937960 pts/sec
2024/01/03 14:20:10 ack: false, Get 30000 points took 0.04, 668062 pts/sec
2024/01/03 14:20:10 ack: true, Get 30000 points took 0.04, 827364 pts/sec
2024/01/03 14:20:10 ack: false, Get 30000 points took 0.03, 881960 pts/sec

Seems fast enough.

Syncing streams between hub and leaf nodes:

[cbrake@quark nats-exp]$ go run ./bi-directional-sync/
=====================================================
       Create stream on hub and source to leaf
=====================================================
* Create stream: server:hub domain:hub stream:NODES-HUB subject:n.hub.>
* Publish: hub -> n.hub.123.value -> 12 13 14 15
* Stream count: server:hub domain:hub stream:NODES-HUB count:4
* Stream count: server:leaf domain:hub stream:NODES-HUB count:4
* Source stream: server:leaf domain:leaf stream:NODES-HUB source-domain:hub subject:n.hub.>
* Stream count: server:leaf domain:leaf stream:NODES-HUB count:4
=====================================================
       Create stream on leaf and source to hub
=====================================================
* Create stream: server:leaf domain:leaf stream:NODES-LEAF subject:n.leaf.>
* Publish: leaf -> n.leaf.456.value -> 22 23 24 25 26
* Source stream: server:hub domain:hub stream:NODES-LEAF source-domain:leaf subject:n.leaf.>
* Stream count: server:hub domain:hub stream:NODES-LEAF count:5
=====================================================
       Shut down leaf node
=====================================================
* Stream count: server:hub domain:hub stream:NODES-LEAF count:5
* Publish: hub -> n.hub.123.value -> 16 17 18 19
* Stream count: server:hub domain:hub stream:NODES-HUB count:8
=====================================================
       Start up leaf node
=====================================================
* Stream count: server:leaf domain:leaf stream:NODES-HUB count:8
* Publish: hub -> n.hub.123.value -> 20 21 22 23
* Stream count: server:leaf domain:leaf stream:NODES-HUB count:12
=====================================================
       Publish more messages to leaf
=====================================================
* Publish: leaf -> n.leaf.456.value -> 27 28 29 30 31
* Stream count: server:leaf domain:leaf stream:NODES-LEAF count:10
* Stream count: server:leaf domain:leaf stream:NODES-LEAF count:10