Optimize WebSocket connection performance
- Open the fewest connections that can still serve the workflow.
- Subscribe only to the feeds and filters the client actually needs.
- Process messages in connection order and keep reconnect state explicit.
- Avoid control-plane churn that creates avoidable WebSocket pressure.
- Reconcile after reconnect instead of assuming the socket stayed perfect.
Start with subscription shape, not micro-optimizations
- Pick the exact feeds needed for the workflow.
- Filter by symbol, trader, strategy, or reason wherever the feed supports it.
- Keep market-data and user-data consumption logically separate, even if they share one connection.
- Use REST for initial snapshots so the WebSocket can focus on live updates.
Preserve ordering guarantees
- apply updates in top-level
ordinalorder per connection - use
globalOrdinalonly within one update family - use
orderMatchOrdinalplus per-orderordinalto reconstruct multi-outcome matches - do not merge unrelated connection streams without a clear ordering model
Reduce WebSocket overhead
- Avoid repeated subscribe and unsubscribe loops for short-lived views.
- Keep callbacks lightweight and hand off heavy processing to a separate queue or worker stage.
- Reuse one durable connection where possible instead of opening many competing sockets.
- Monitor heartbeat and acknowledgement health so a degraded connection is detected before the state model drifts badly.
Reconnect the same way every time
- Store the active subscription set.
- Re-open the connection.
- Resubscribe in a controlled order.
- Resume one update family with its own
globalOrdinal. - Run REST reconciliation for any state that must be exact.