One user, many devices
Real users connect from a phone, a laptop, and an iPad simultaneously. A naive user_id → ws map breaks the moment that happens — the second connection silently overwrites the first. The fix is a one-to-many index: user_id → set of connection_ids, and a separate connection_id → WebSocket.
Connection IDs
Generate a random ID at connect time and use it everywhere internally. The client does not need to know it. This makes broadcasting "to this connection" possible without exposing implementation details, and lets you add per-connection rate limits, telemetry, and session metadata.