Created
April 3, 2014 21:56
-
-
Save jeffreytgilbert/9963702 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var | |
express = require( 'express' ), | |
connect = require('connect'), | |
app = express(); | |
count = 0; | |
app.configure( function() { | |
app.use(connect.urlencoded()); | |
app.use(connect.json()); | |
}); | |
function log( what ) { console.log( what ); } | |
app.get( '/', function( req, res ) { | |
count++; | |
res.end(count+' bottles of beer on the wall!'); | |
}); | |
app.listen( 8080 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cluster = require('cluster') | |
if ( cluster.isMaster ) { | |
for ( var i=0; i<8; ++i ) | |
cluster.fork(); | |
} else { | |
var | |
express = require( 'express' ), | |
connect = require( 'connect' ), | |
app = express(), | |
count = 0; | |
app.configure( function() { | |
app.use(connect.urlencoded()); | |
app.use(connect.json()); | |
}); | |
function log( what ) { console.log( what ); } | |
app.get( '/', function( req, res ) { | |
count++; | |
res.end(count+' bottles of beer on the wall!'); | |
}); | |
app.listen( 8080 ); | |
} |
Definitely true. Was just testing the scaling limits of node cluster out of the box on version 0.10, and the performance gains weren't useful because of the native process scheduling. Varnish, nginx, HA proxy, etc are better solutions for this while we wait and see what kind of gains we can get from 0.12
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try using strong-supervisor, you can control worker count from command line (or strongops): https://github.com/strongloop/strong-supervisor
Not to tout our modules too much... but better than changing that
8
into other numbers.