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

NodeJS clusters - do they share anything?

NodeJS clusters - do they share anything?

Problem

How does node cluster work? Is it a share nothing architecture? Is the session guaranteed to be directed to the same worker? The docs are pretty sparse.

Thanks!

Problem courtesy of: CamelCamelCamel

Solution

No, they are not guaranteed to be directed to the same worker based on a session. It generally follows a round-robin pattern to load balance the connections, but this is determined by the operating system (more info in this Discussion - https://groups.google.com/d/topic/nodejs/svIXu5wUXCI/discussion).

If you need to access data for a specific session I would recommend storing the data in some kind of a data store - either your database or some in-memory store for faster access (e.g. Redis).

Solution courtesy of: Lalit Kapoor

Discussion

View additional discussion.



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

Share the post

NodeJS clusters - do they share anything?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×