Skip to content

Instantly share code, notes, and snippets.

@arunoda
Created February 9, 2014 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arunoda/8897718 to your computer and use it in GitHub Desktop.
Save arunoda/8897718 to your computer and use it in GitHub Desktop.
var DDPClient = require('ddp');
var totalClients = 0;
var postsList = 0;
var postsListUsers = 0;
var postsList
function createClient(closeTimeout) {
console.log('CREATING....', closeTimeout);
var client = new DDPClient({
host: "107.170.25.58",
port: 80
});
client.connect(function(err) {
if(err) throw err;
console.log('connected - ', ++totalClients);
client.subscribe('postsList', [{"view":"preload"}], function() {
postsList++;
});
client.subscribe('postsListUsers', [{"view":"preload"}], function() {
postsListUsers++;
});
});
client.on('socket-close', function(code, message) {
postsListUsers--;
postsList--;
totalClients--;
console.log('disonnected - ', totalClients, postsList, postsListUsers);
});
setTimeout(function() {
client.close();
}, closeTimeout);
return client;
}
setInterval(function() {
console.log('STATUS:', totalClients, postsList, postsListUsers);
}, 5000);
// createClient(50000);
var olderClient = 0;
setInterval(function() {
//20session/sec => 60 * 20 session total
for(var lc=0; lc<20; lc++) {
createClient(1000 * 60);
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment