jeudi 19 février 2015

Scale NodeJS SocketIO Redis One on One Chat

I am creating one on on chat using nodejs,socketio and redis pubsub.


At each new connection I create a connection to redis(subscriber) so that anyone can publish to that connection.



io.on('connection', function (socket) {

//creating redis connection
var sub = redis.createClient(redis_port,redis_ip);

socket.on("add user",function(msg){
my_id=msg;
sub.subscribe(msg);
sub.on('message',function (channel,msg){
console.log("redis sub got something"+msg);
socket.emit('chat_client', JSON.parse(msg),function (ack){
}

);
});
}
);


Now problem is I am not able to make more than max TCP ports number of connections(breaking at 30K).How can we solve this problem where each socket.io connection is creating a redis connection?


Aucun commentaire:

Enregistrer un commentaire