Right now I have a word game where users are randomly paired up and send messages to each other. I am using Node.js and Socket.io. Basically, I'm storing the socket.id as the key for an object of users. One of the properties is the socket.id of their partner. So when someone sends a message, I have logic to find that user and get their partner socket.id, and then I send the message to that specific socket.id.
However, this is not going to work when I have multiple instances of Node behind NGINX or some other loadbalancer. I've looked into using a tool such as Redis, however every example I've found involves sending the same message to users across instances. I am not sending the same message to thousands of people across multiple instances. I am only sending messages between two people, however many of these little chatrooms need to exist. What if two users can't get paired because they are on different instances of Node? Even then, I feel like I shouldn't be sending every message to every instance of Node and doing nothing with it on all instances except the one the partner is connected to.
Any information on tackling this kind of problem would be greatly appreciated.