~/writing/notes/websocket-backpressure
seedlingSlow WebSocket clients are a backpressure problem
One slow reader can stall a fan-out loop. Give every connection a bounded buffer and drop or disconnect when it fills.
planted 1 min read
The fan-out loop must never block on a client. Each connection gets a buffered channel; the broadcaster does a non-blocking send and, if the buffer is full, either drops the message (presence, cursors) or closes the connection (anything that must be complete).
go
select {
case c.send <- msg:
default:
c.close(websocket.ClosePolicyViolation) // too slow, reconnect and resync
}Still working out: when to resync from a snapshot versus replaying a short log. Context: Sub-millisecond WebSocket fan-out in Go: the Vedico realtime service, A sub-100ms personalised surge-pricing engine for a US food marketplace.
Links from this note
Feb 5, 2026Sub-millisecond WebSocket fan-out in Go: the Vedico realtime serviceHow a single Go service pushes GPS telemetry from hundreds of field technicians to NOC dashboards in under a millisecond, with back-pressure, per-region isolation and no shared locks on the hot path.Read May 30, 2025A sub-100ms personalised surge-pricing engine for a US food marketplaceRead