Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run multiple instances of node.js in parallel

I was thinking about using a reverse proxy to distribute API requests to multiple node.js instances of a REST API. Like this it should be possible to achieve much better overall performance since multiprocessor systems can perfectly run multiple instances on one core each (or similar).

What are common solutions for such a distribution of requests onto multiple node instances and what are important points to take in mind?

like image 923
s1lence Avatar asked Feb 29 '12 13:02

s1lence


1 Answers

First and foremost, you can use the cluster module for running many instances of the same server application. It's important to remember to correctly handle shared state, such as storing sessions in a common database.

This works standalone and you can let your users connect directly to that server, or use e.g. nginx, HAProxy, Varnish or lighttpd in front of your server.

like image 192
Linus Thiel Avatar answered Sep 29 '22 08:09

Linus Thiel