on a basic node http server like this:

var http = require('http');
var server = http.createServer(function(req, res){

  console.log("number of concurr. connections: " + this.getConnections());
  //var pendingConnections = ???
});

server.maxConnections = 500;

server.listen(4000);

if i send 500 requests at one time to the server, the number of concurr. 
connections is arround 350. with the hard limit set to 500 (
net.server.backlog too), i want to know, how to access the number of 
pending connections (max. 150 in this example) when ever a new request 
starts.

so i think i have to access the underlying socket listening on port 4000 to 
get this info, but until now i was not able to get it.

*EDIT*

looking at node-http there is an event called connection, so i think the 
roundtrip of an request is as follows:

   1. client connects to server socket --> 3-way-handshake, socket lasts in 
   state CONNECTED (or ESTABLISHED ?!) then in node event connection is 
   emitted.
   2. the node http server accepts this pending connection an starts 
   processing the request by emitting request

so the number of connections has to be at least as big as the number of 
requests, but with following example i could not confirm this:

var http = require('http');
var activeRequets = 0;var activeConnections = 0;
var server = http.createServer(function(req, res){

    activeRequests++;
    res.send("foo");
});

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

    socket.setKeepAlive(false);
    activeConnections++;
});

setInterval(function(){

    console.log("activeConns: " + activeConnections + " activeRequests: " + 
activeRequests);
    activeRequests = 0;
    activeConnections = 0;
}, 500);

server.maxConnections = 1024;
server.listen(4000, '127.0.0.1');

even if i stress the server with 1000 concurr connections and adding one 
delay in the response, activeRequests is mostly as high as activeConnections. 
even worse, the activeRequests are often higher then activeconnections, how 
could this be?

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to