Scaling WebSockets Across Multiple Go Servers with Redis
· 7 min read
A stateless HTTP handler scales the boring way: put a load balancer in
front, add replicas, done — any instance can answer any request because no
instance holds anything the others need. A WebSocket server breaks that
model by definition. The connection is the state. If Alice is connected to
node B and your billing webhook fires on node A and calls
hub.SendToUser("alice", ...), node A's hub has no idea Alice exists. The
message doesn't error, doesn't queue, doesn't retry — it just isn't
delivered, because from node A's point of view there's no client called
Alice.