Multiple now clients in one node instance

44 views
Skip to first unread message

Brendan

unread,
Mar 18, 2012, 7:50:08 PM3/18/12
to nowjs
hi all,

I want to use a node instance to stress my node server. I could do
something like this on my node instance:

var nowjs = require('../node_modules/now/lib/nodeclient/now.js');
for (var i = 0; i < 10; i++)
now[i] = nowjs.nowInitialize('http://localhost:8080');

but the code in now/lib/nodeclient/now.js sees the same URL being used
and returns a prior instance.

Is there a good way to establish multiple now instances on a single
node instance, to really stress my server?

thanks!

Brendan

unread,
Mar 19, 2012, 4:24:37 AM3/19/12
to nowjs
For anyone following from home, I hacked up a solution that seems to
work.

I modified now/lib/nodeclient/now.js in a couple ways:

- Get rid of the code that returns an existing now instance for the
same URI, i.e. get rid of:

if (Object.prototype.hasOwnProperty.call(nowObjects, uri)) {
return nowObjects[uri];
}

- Force socket.io to create a new connection for the same URI, rather
than reusing an existing one:

var socket = io.connect(uri, { 'force new connection': true });


Now I can stress test my node server using now, which is really neat.

Would love to hear if there's a better way of doing this!
Reply all
Reply to author
Forward
0 new messages