简体   繁体   English

Node.js事件和集群

[英]Node.js events and cluster


I am using Node.js with events-module . 我正在使用带有事件模块的 Node.js。 I want to use all the cpu-cores, so I have read about cluster-module . 我想使用所有的cpu-core,所以我已经阅读了有关cluster-module的信息
Does these two modules work togheter? 这两个模块是否可以正常工作? If the event is triggered in a different cpu-core? 是否在其他cpu-core中触发了事件?

Thanks for your help. 谢谢你的帮助。

No, events triggered through Node.js EventEmitter are only fired within one process. 不,通过Node.js EventEmitter触发的事件仅在一个进程内触发。 You can trigger message event from worker to master process with Cluster API or you can use external message hub ie Redis Pub/Sub or RabbitMQ 您可以使用Cluster API触发从工作程序到主进程的message事件,也可以使用外部消息中心,即Redis Pub / SubRabbitMQ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM