Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

run multiple instances of node.js in parallel

run multiple instances of node.js in parallel

Problem

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?

Problem courtesy of: s1lence

Solution

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.

Solution courtesy of: Linus Gustav Larsson Thiel

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

run multiple instances of node.js in parallel

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×