I scaled on a single machine using haproxy and thalassa. The gist of it:
var http = require('http')
var app = require('./app')
var pkg = require('./package.json')
var server = http.createServer()
server.on('request', app)
// Listen on port 0. This finds a random, free port.
server.listen(0, funciton () {
var port = server.address().port
// Here you would register the port / host combination with some sort of
// registry, which would dynamically update haproxy. In my case I used
// thalassa.
//
// registry.register('myservice', pkg.version, port)
// registry.start()
})
What I love about this approach is that you can easily go multi-machine later
down the track.
On Thu, Dec 19, 2013 at 08:50:03AM -0800, Bijuv V wrote:
> Hi ,
>
> I have a Web server with an Application developed using express. In the
> application we do mention the port at which the application should listen
> for requests. For eg 3000.
>
> If I spawn multiple node processes on the same machine, there will be a
> conflict on the ports. How can this be achieved (apart from the below
> options)?
>
> The options that Im aware of are
> a. Use Cluster feature of node. Everything is handled by node. Still
> experimental AFAIK.
> b. Use multiple VM's to deploy each instance
> c. start node on different ports - 3001 - 3008. Put a hardware LB before
> the same which will send the requests to one of the Node instances. - Dont
> want to invest on a H/W LB.
>
> I was watching the video from Ryan.
> http://www.youtube.com/watch?v=F6k8lTrAE2g
>
> He mentions about the limitations of node being single threaded and also
> talks about server file descriptors usage to build Web Servers. However, I
> could not get the details of how the file descriptors should be configured
> so that the requests go to one of the 8 instances on the machine.
>
> --
> --
> 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.
signature.sig
Description: Digital Signature
