TCP, NAT, Port Exhaustion, WebSockets, and SSE
TCP flow control protects the receiver; congestion control adapts sending behavior to network conditions. High connection churn to a small set of destinations can exhaust ephemeral ports or NAT state. Reuse connections where appropriate and monitor resets, retransmissions, connection counts, and NAT utilization.
WebSockets provide bidirectional persistent communication. Server-Sent Events (SSE) provide a server-to-client stream, while long polling holds HTTP requests open until data or a timeout is available. Select based on interaction direction, infrastructure compatibility, and client behavior.
Persistent connections require heartbeats, reconnect backoff, connection limits, graceful draining, and resume cursors. Real-time transport is not durable storage: clients should resynchronize from authoritative state after reconnecting.
- Connection churn can exhaust ports or NAT tracking state.
- WebSocket, SSE, and long polling have different interaction semantics.
- Use cursors to recover missed events after reconnects.