NodeJS clusters – do they share anything?

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

Node.js Recipes责编内容来自:Node.js Recipes (源链) | 更多关于

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » NodeJS clusters – do they share anything?

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录