docs(streaming): add 'Things to consider' on high-frequency WS usage and throttling
Notes on heap fragmentation, UDP saturation, throttling/coalescing, buffer reuse, yielding, and payload sizing for reliable streaming/broadcast.
This commit is contained in:
@@ -78,3 +78,21 @@ Notes:
|
|||||||
Related docs:
|
Related docs:
|
||||||
- [`ClusterBroadcast.md`](./ClusterBroadcast.md) — centralized UDP broadcasting and CLUSTER_EVENT format
|
- [`ClusterBroadcast.md`](./ClusterBroadcast.md) — centralized UDP broadcasting and CLUSTER_EVENT format
|
||||||
|
|
||||||
|
### Things to consider
|
||||||
|
|
||||||
|
- High-frequency updates can overwhelm ESP8266:
|
||||||
|
- Frequent JSON parse/serialize and `String` allocations fragment heap and may cause resets (e.g., Exception(3)).
|
||||||
|
- UDP broadcast on every message amplifies load; WiFi/UDP buffers can back up.
|
||||||
|
- Prefer ≥50–100 ms intervals; microbursts at 10 ms are risky.
|
||||||
|
- Throttle and coalesce:
|
||||||
|
- Add a minimum interval in the core `cluster/broadcast` handler.
|
||||||
|
- Optionally drop redundant updates (e.g., same color as previous).
|
||||||
|
- Reduce allocations:
|
||||||
|
- Reuse `StaticJsonDocument`/preallocated buffers in hot paths.
|
||||||
|
- Avoid re-serializing when possible; pass-through payload strings.
|
||||||
|
- Reserve `String` capacity when reuse is needed.
|
||||||
|
- Yielding:
|
||||||
|
- Call `yield()` in long-running or bursty paths to avoid WDT.
|
||||||
|
- Packet size:
|
||||||
|
- Keep payloads small to fit `ClusterProtocol::UDP_BUF_SIZE` and reduce airtime.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user