From d9ec356f10fd92e9044c760b3e0f0c2b7462d14c Mon Sep 17 00:00:00 2001 From: Audric Date: Tue, 28 Apr 2026 11:30:50 +0200 Subject: [PATCH] mqtt: raise default STATUS_INTERVAL from 1000 ms to 30000 ms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The full-status snapshot is a bootstrap / drift-correction mechanism; per-event topics (talker, client, trunk, nodes) already deliver every change live. The retained payload scales with mesh size — at a few hundred nodes with the rich per-client status blob it is hundreds of KB, which makes a 1 s republish expensive on broker bandwidth and reflector CPU. Lower it explicitly via [MQTT] STATUS_INTERVAL only when a small mesh has a consumer that depends on near-real-time full snapshots. Test configs keep STATUS_INTERVAL=1000 to verify retained-status behaviour in seconds. --- README.md | 2 +- docs/MQTT.md | 6 +++--- src/svxlink/reflector/Reflector.cpp | 12 ++++++++++-- src/svxlink/reflector/svxreflector.conf.in | 9 ++++++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a13231d..87b9adf 100644 --- a/README.md +++ b/README.md @@ -403,7 +403,7 @@ PORT=1883 USERNAME=reflector PASSWORD=secret TOPIC_PREFIX=svxreflector/myreflector -STATUS_INTERVAL=1000 +STATUS_INTERVAL=30000 ``` Omit the `[MQTT]` section entirely to disable — zero overhead when not diff --git a/docs/MQTT.md b/docs/MQTT.md index 4d32034..773524e 100644 --- a/docs/MQTT.md +++ b/docs/MQTT.md @@ -34,7 +34,7 @@ not configured. | `USERNAME` | Yes | — | Broker authentication username | | `PASSWORD` | Yes | — | Broker authentication password | | `TOPIC_PREFIX` | Yes | — | Base topic path (e.g. `svxreflector/myreflector`) | -| `STATUS_INTERVAL` | No | 1000 | Periodic full status publish interval in milliseconds | +| `STATUS_INTERVAL` | No | 30000 | Periodic full status publish interval in milliseconds. The full snapshot is a bootstrap/drift-correction mechanism — per-event topics already deliver every change live, so raising this is cheap. Lowering it below ~1 s is expensive once a mesh exceeds a few hundred nodes (retained payload is hundreds of KB). | | `TLS_ENABLED` | No | 0 | Enable TLS encryption (`0` or `1`) | | `TLS_CA_CERT` | If TLS | — | Path to CA certificate file | | `TLS_CLIENT_CERT` | No | — | Path to client certificate (mutual TLS only) | @@ -162,8 +162,8 @@ subscribers see the last-known roster immediately. ### Periodic full status -Published at the configured `STATUS_INTERVAL` (default every 1 second). The -payload is identical to the HTTP `/status` JSON response. +Published at the configured `STATUS_INTERVAL` (default every 30 seconds). +The payload is identical to the HTTP `/status` JSON response. ``` {TOPIC_PREFIX}/status diff --git a/src/svxlink/reflector/Reflector.cpp b/src/svxlink/reflector/Reflector.cpp index b8c3abc..8cb3721 100644 --- a/src/svxlink/reflector/Reflector.cpp +++ b/src/svxlink/reflector/Reflector.cpp @@ -492,8 +492,16 @@ bool Reflector::initialize(Async::Config &cfg) } else { - // Set up periodic status publishing - unsigned status_interval = 1000; + // Set up periodic status publishing. + // Default 30 s: the full snapshot is intended as a drift-correction / + // bootstrap mechanism for new subscribers. Real-time changes already + // reach the broker via the per-event topics (talker/start|stop, + // client/connected|disconnected, trunk/up|down, nodes/local, + // nodes/). Republishing the full m_status every second is + // proportional to the number of nodes in the mesh — at a few + // hundred nodes with rich per-client status it becomes hundreds of + // KB/s of largely redundant retained traffic. + unsigned status_interval = 30000; cfg.getValue("MQTT", "STATUS_INTERVAL", status_interval); m_mqtt_status_timer.setTimeout(status_interval); m_mqtt_status_timer.setEnable(true); diff --git a/src/svxlink/reflector/svxreflector.conf.in b/src/svxlink/reflector/svxreflector.conf.in index b149a8c..e40e931 100644 --- a/src/svxlink/reflector/svxreflector.conf.in +++ b/src/svxlink/reflector/svxreflector.conf.in @@ -202,7 +202,14 @@ CERT_CA_HOOK=@SVX_SHARE_INSTALL_DIR@/ca-hook.py # //... — useful when several reflectors share # the same TOPIC_PREFIX. Leave unset to keep topics flat. #MQTT_NAME=reflector-01 -#STATUS_INTERVAL=1000 +# Periodic full-status publish interval in milliseconds (default 30000). +# The full snapshot is a bootstrap/drift-correction tool for new MQTT +# subscribers — per-event topics already deliver every change live. +# Lower this only if you have a small mesh and a consumer that depends +# on near-real-time full snapshots; at hundreds of nodes the retained +# payload is hundreds of KB and republishing it once per second is +# expensive on broker bandwidth and reflector CPU. +#STATUS_INTERVAL=30000 #TLS_ENABLED=0 #TLS_CA_CERT=/path/to/ca.crt #TLS_CLIENT_CERT=/path/to/client.crt