Creating a node.js application is simple enough.
var app = require(\'express\')();
app.get(\'/\',function(req,res){
res.send(\"Hello world!\");
});
>
There are many many ways to deal with this, but it boils down to 2 things:
For the first option, you can user node-cluster
or the same solution as for the seconde option. node-cluster
(http://nodejs.org/api/cluster.html) essentially is a built in way to fork the node process into one master and multiple workers. Typically, you'd want 1 master and n-1 to n workers (n being your number of available cores).
The second option is to use a load balancer that distributes the requests amongst multiple workers (on the same server, or across servers).
Here you have multiple options as well. Here are a few:
upstream
server)One more thing, once you start having multiple processes serving requests, you can no longer use memory to store state, you need an additional service to store shared states, Redis (http://redis.io) is a popular choice, but by no means the only one.
If you use services such as cloudfoundry, heroku, and others, they set it up for you so you only have to worry about your app's logic (and using a service to deal with shared state)