Add exhaustive NATS factorial, MQTT/UDP probes, and optimal-config report.
Some checks are pending
offline / test (push) Waiting to run

Compares r=1 vs r=3, file vs memory, reconnect tax, and projects three
HP DL360 Gen10 NVMe + 10GbE boxes. Keep NATS; do not switch to MQTT/UDP.
This commit is contained in:
George Lambert 2026-09-12 02:06:03 -04:00
parent a7a7ec86ce
commit c83f1c6717
77 changed files with 5089 additions and 4 deletions

View file

@ -1,9 +1,10 @@
#!/usr/bin/env node
/**
* Pubsub round trip through the cluster (two connections).
* Usage: NATS_URL=... node latency.mjs [count] [payloadBytes] [publishers] [ping|flood]
* ping = sequential publish-wait (one-message RTT)
* flood = publish the batch then drain (queueing under burst)
* Usage: NATS_URL=... node latency.mjs [count] [payloadBytes] [publishers] [ping|flood|reconnect]
* ping = sequential publish-wait on persistent sockets (one-message RTT)
* flood = publish the batch then drain (queueing under burst)
* reconnect = connect, one publish, wait, close measures handshake tax
*/
import { connect, headers } from "nats";
@ -23,7 +24,33 @@ function pct(sorted, p) {
}
const samples = [];
if (mode === "ping") {
if (mode === "reconnect") {
const subNc = await connect({ servers, name: "lat-sub" });
let resolveOne = null;
const sub = subNc.subscribe(subject, { max: count });
const consume = (async () => {
for await (const m of sub) {
const sent = Number(m.headers?.get("t") || 0);
samples.push(Number(process.hrtime.bigint() / 1000n) - sent);
resolveOne?.();
}
})();
await subNc.flush();
for (let i = 0; i < count; i++) {
const got = new Promise((r) => {
resolveOne = r;
});
const pubNc = await connect({ servers, name: `lat-re-${i}` });
const h = headers();
h.set("t", String(process.hrtime.bigint() / 1000n));
pubNc.publish(subject, payload, { headers: h });
await pubNc.flush();
await got;
await pubNc.close();
}
await consume;
await subNc.close();
} else if (mode === "ping") {
const subNc = await connect({ servers, name: "lat-sub" });
const pubNc = await connect({ servers, name: "lat-pub" });
let resolveOne = null;