The sticky-session problem
WebSocket connections are persistent and stateful — they live on a specific server process. When a client reconnects, they may hit a different server with no memory of their session, room membership, or auth context. Sticky sessions ensure that reconnections from the same client land on the same server.
Three sticky strategies
IP hash: simplest, works without cookies, breaks behind shared NATs (university wifi, corporate VPN). Cookie-based affinity: precise, but cookies are not always set in time for the first WebSocket upgrade. Connection-aware (least-conn): distributes load evenly but provides no affinity — only good when your servers are stateless or you have a Redis bridge to compensate.