Node.js chat app and clusters

I'd like to make chatroulette app with node.js and: socket.io, cluster - modules/plugins.

So I have master-cluster who just create a few sub-clusters. Now, each sub-cluster has socket.io connection on same port. But where should I combine into pairs all sockets(users), in which sub-cluster? Some sockets are in one cluster, and some sockets in other cluster.

I can sync all socket.io connections by this clusterhub: http://toolbox.no.de/packages/socket.io-clusterhub

So each cluster has all sockets, but which sub-cluster should combine sockets into pairs? Generally I need to do some things over sub-clusters, and need access to all sockets from all sub-clusters.

You will need to connect your different socket.io instances with either Message Queue or a Socket.IO Store so they communicate with each other and pass of the message to a different instance.

Socket.IO already has a concept of Stores which is used to store connections it's socket.io's answer to deploying multiple servers and processes. Socket.IO ships with 2 stores, the memory store that will keep all connection information inside process and a RedisStore that will sync all the information between all the connected processes.

See https://github.com/LearnBoost/Socket.IO/wiki/Configuring-Socket.IO (section about stores) for more information on how you can implement that.