I have watched the same failure play out in real-time features more than once. One server, one room, everything works. You add a second instance behind a load balancer to handle more connections, and half your users stop receiving messages. Nobody changed the room code. Nobody changed the gateway. The system just got bigger, and the thing that worked at one instance quietly stopped working at two.
The cause is simple, and that is what makes it dangerous. Socket.io rooms live in memory by default. Instance A knows its own sockets. Instance B knows its own sockets. Neither knows the other's. When instance A broadcasts to a room, it only talks to the sockets it can see.
This post is the fix I reach for in NestJS: the Redis adapter, the sticky-session rule that makes it actually work, and a room pattern that stops you from rebuilding the same in-memory trap in a new place.…