my code keeps using setinterval to fetch redis data (redis is on another server). Dozens of people access the network outflow bandwidth (bit/s) of the redis server at the same time.
whether there should be a cache or what dozens of people access at the same time causes dozens of links to request more REDIS users to increase bandwidth exponentially
//
io.sockets.on("connection", function (socket) {
//console.log("...");
//
onlineCountPP;
var domain = socket.handshake.headers.origin;
if(typeof domain == "undefined"){
return;
}
socket.volatile.emit("onlinenums", {polotime: res[2]});
});
});
}
var once = setTimeout(refresh,100);
var tweets = setInterval(refresh, 2000);
console.log(":"+onlineCount);
//
socket.on("disconnect", function() {
clearInterval(tweets);
if(onlineCount > 0 ){
//
onlineCount--;
console.log(":"+onlineCount);
}
});
});
//HTTP3000
app.listen(3000, function(){
console.log("listening on *:3000");
});