Hi all,

I am new to node.js and to start I am doing some tests.
In particular I am trying to open 4 sessions of a simple server on ports: 
8001, 8002, 8003, and 8004.
The only task of the simple server is to write "hello world".
Moreover I have a script based on node-http-proxy to load balance the 
requests to the opened sessions.

This is the code of simpleServer.js:

var http = require("http");
var port = process.argv[2];

http.createServer(function(request, response) {
  response.writeHead(200);
  response.end("Hello world");
}).listen(port);



And this is the code of the load balancer nodeHttpProxy.js

var httpProxy = require('http-proxy');
//
// A simple round-robin load balancing strategy.
// 
// First, list the servers you want to use in your rotation.
//
var addresses = [
  {
    host: 'localhost',
    port: 8001
  },
  {
    host: 'localhost',
    port: 8002
  },
  {
    host: 'localhost',
    port: 8003
  },
  {
    host: 'localhost',
    port: 8004
  }
];

httpProxy.createServer(function (req, res, proxy) {
  //
  // On each request, get the first location from the list...
  //
  var target = addresses.shift();

  //
  // ...then proxy to the server whose 'turn' it is...
  //
  // console.log('balancing request to: ', target);
  proxy.proxyRequest(req, res, target);

  //
  // ...and then the server you just used becomes the last item in the list.
  //
  addresses.push(target);
}).listen(80);




For testing, I open a terminal and launch four sessions of simpleServer,js 
for each port and then I run httpNodeProxy.js.
Finally I launch the command:

ab -n 100000 -c 100 http://127.0.0.1/



and this is the result:

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
apr_poll: The timeout specified has expired (70007)
Total of 33235 requests completed


Do anyone know why the test do in timeout?

Is there any error in my scripts or any configurations limit in node.js or 
my Linux CentOS 6.5 (vergin new installation) ?


Thank you!
Elaidon

-- 
-- 
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/groups/opt_out.

Reply via email to