How can I match connected websockets in Node JS to a new message that is saved?

I have a Node / Express based server that uses Mongodb / Mongoose as it's data store. The clients are iOS apps that mostly access data (posts) using a REST API on the server. However, the client user can also start a chat on individuals posts in the app, which require that the user find out immediately if a new message is posted for that specific chat/post. This is handled by opening a websocket between the iOS app (socketrocket) and the server (Einaros WS socket).

Each chat involves only a handful of the total number of users on the system (e.g. 2 - 5 of the thousands of active users), and there are many concurrent chats on different posts. When a new message is received by the server (using an HTML POST), I need to figure out how to inform just the corresponding websockets of that message. Ideally I would like to only iterate through the 2-5 users that are connected to one post rather than the full list of all open sockets.

What would be the best way to store and access this list of sockets (for a post) without going through all of the open sockets, and blocking the event loop? Are there better ways to do this without using sockets at all, since I only care about the notification from server to client that a new message is available? I debated using long polling as well but ran into issues when trying to store the Express response object.

I'm thinking that the incoming message handler would look something like below where I can access the list of sockets for each story, but storing sockets in the database feels strange to me.

app.post('/api/message', isLoggedInAPI, function(req, res) {
    var story_id = req.body.story_id;
    var text = req.body.message;
    var message = {text: text, sender: req.user._id};

    Story.findByIdAndUpdate(story_id, {$push: {messages: message}}, {safe: true, upset: true})
        .execAsync()
        .catch(function(err) {
            res.status(404).end();
            Promise.resolve();
        })
        .then(function(story){
        //  console.log(story, story_id);
                if(story)
                {
                    //console.log(story, story_id);
                    res.status(200).json({count: story.messages.length});

                    for (var i=0; i< story.pendingResponses.length; i++)
                    {
                        socket = story.pendingResponses[i];

                        // Send message to socket

                    });     
                    }
                    story.pendingResponses.length = 0;

                    story.update({$set: {pendingResponses: []}}, {safe: true, upset: true})
                            .execAsync()
                            .then(function(){

                            })
                            .catch(function(err) {

                            });
                }
                else res.status(404).end();

        }).catch(function(err) {
            res.status(501).send(err).end();
        });
}); 

I was able to solve this by doing the following. When I get a new socket, I store it in an array using the user_id which is unique for each connection.

var clients = [];

store socket with user ID (could store res for long polling the same way)

clients[req.user.id]=socket;  

I store the user_id in an array of pendingResponses for each post / Story, at the same time.

And in my POST api,

for (var i=0; i< story.pendingResponses.length; i++)
    {
       id = story.pendingResponses[i];
       do something with clients[id] to talk to thesocket
    }

This means that for each POST, the event loop will look through pending sockets for that specific story only. I do worry about the scenario of what happens if there are many users connected to the same story, in which case this loop becomes problematic.

To scale this as the number of users grow requires using some sort of messaging queue (such as ZMQ, RabbitMQ, Redis Pub Sub), so that messages from one server instance can be shared with users connected to other instances.