Snapshot of verae-nats-cluster (optimal NATS config study)
This commit is contained in:
commit
8639ca27ee
184 changed files with 10626 additions and 0 deletions
84
scripts/exhaustive-ns1-study.sh
Executable file
84
scripts/exhaustive-ns1-study.sh
Executable file
|
|
@ -0,0 +1,84 @@
|
|||
#!/usr/bin/env bash
|
||||
# Exhaustive NS1 ladder on the *current* 8c/16G cluster with JetStream on ZFS.
|
||||
# Adds r=1 vs r=3, file vs memory, reconnect tax, UDP echo, MQTT gateway probe.
|
||||
# Does not tmpfs (product streams stay). Must run on NS1.
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
export PATH="/usr/sbin:/usr/bin:/bin:/usr/local/bin:$PATH"
|
||||
HOST="$(hostname -f 2>/dev/null || hostname)"
|
||||
case "$HOST" in
|
||||
NS1.GEORGELAMBERT.ORG|NS1|ns1.georgelambert.org|ns1) ;;
|
||||
*) echo "refusing: exhaustive-ns1-study.sh must run on NS1, got '$HOST'" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
export EXHAUSTIVE=1
|
||||
export JS_EXTRA_MEMORY=1
|
||||
export COMPARE_DIR="${COMPARE_DIR:-$ROOT/results/20260912T051237Z}"
|
||||
STAMP="$(date -u +%Y%m%dT%H%M%SZ)"
|
||||
export BENCH_OUT="$ROOT/results/$STAMP"
|
||||
mkdir -p "$BENCH_OUT"
|
||||
|
||||
# MQTT gateway on nats-a only (vmbr1). Restored after.
|
||||
MQTT_CONF=/etc/nats/nats.conf
|
||||
enable_mqtt() {
|
||||
sudo pct exec 511 -- bash -lc '
|
||||
set -e
|
||||
f=/etc/nats/nats.conf
|
||||
grep -q "^mqtt {" "$f" && exit 0
|
||||
cat >> "$f" <<EOF
|
||||
|
||||
mqtt {
|
||||
host: 10.10.10.21
|
||||
port: 1883
|
||||
}
|
||||
EOF
|
||||
systemctl kill -s HUP nats-server || systemctl restart nats-server
|
||||
'
|
||||
sleep 2
|
||||
}
|
||||
disable_mqtt() {
|
||||
sudo pct exec 511 -- bash -lc '
|
||||
f=/etc/nats/nats.conf
|
||||
python3 - "$f" <<'"'"'PY'"'"'
|
||||
from pathlib import Path
|
||||
import re, sys
|
||||
p = Path(sys.argv[1])
|
||||
t = re.sub(r"\nmqtt \{[^}]*\}\n", "\n", p.read_text(), flags=re.S)
|
||||
p.write_text(t)
|
||||
PY
|
||||
systemctl kill -s HUP nats-server || true
|
||||
' || true
|
||||
}
|
||||
|
||||
enable_mqtt
|
||||
trap disable_mqtt EXIT
|
||||
|
||||
bash "$ROOT/scripts/study-on-ns1.sh"
|
||||
OUT="$BENCH_OUT"
|
||||
echo "exhaustive extras into $OUT"
|
||||
|
||||
# UDP echo: server in 511, client in 510
|
||||
sudo pct exec 511 -- bash -lc 'pkill -f "udp-probe.mjs server" >/dev/null 2>&1 || true'
|
||||
sudo pct exec 511 -- bash -c 'cat > /tmp/udp-probe.mjs' < "$ROOT/scripts/udp-probe.mjs"
|
||||
sudo pct exec 510 -- bash -c 'cat > /tmp/nats-lat/udp-probe.mjs' < "$ROOT/scripts/udp-probe.mjs"
|
||||
sudo pct exec 511 -- bash -lc 'setsid node /tmp/udp-probe.mjs server 9999 >/tmp/udp-echo.log 2>&1 < /dev/null &'
|
||||
sleep 1
|
||||
echo "=== udp-ping-1k-128 ===" | tee "$OUT/udp-ping-1k-128.txt"
|
||||
sudo pct exec 510 -- bash -lc 'node /tmp/nats-lat/udp-probe.mjs client 10.10.10.21 1000 9999 128' | tee -a "$OUT/udp-ping-1k-128.txt"
|
||||
sudo pct exec 511 -- bash -lc 'pkill -f "udp-probe.mjs server" || true'
|
||||
|
||||
# MQTT QoS0
|
||||
sudo pct exec 510 -- bash -lc '
|
||||
set -e
|
||||
cd /tmp/nats-lat
|
||||
if [[ ! -d node_modules/mqtt ]]; then npm install --no-audit --no-fund mqtt@10 >/dev/null; fi
|
||||
'
|
||||
sudo pct exec 510 -- bash -c 'cat > /tmp/nats-lat/mqtt-probe.mjs' < "$ROOT/scripts/mqtt-probe.mjs"
|
||||
echo "=== mqtt-qos0-5k-128 ===" | tee "$OUT/mqtt-qos0-5k-128.txt"
|
||||
sudo pct exec 510 -- bash -lc 'cd /tmp/nats-lat && node mqtt-probe.mjs mqtt://10.10.10.21:1883 5000 128' | tee -a "$OUT/mqtt-qos0-5k-128.txt" || echo '{"error":"mqtt probe failed"}' | tee -a "$OUT/mqtt-qos0-5k-128.txt"
|
||||
|
||||
python3 "$ROOT/scripts/build-optimal-report.py" "$OUT" \
|
||||
"$ROOT/results/20260912T045131Z" \
|
||||
"$ROOT/results/20260912T051237Z" \
|
||||
"$ROOT/results/20260912T053120Z"
|
||||
echo "exhaustive complete $OUT"
|
||||
Loading…
Add table
Add a link
Reference in a new issue