[翻译]  What are the effective differences between child_process.fork and cluster.fork?

[CHINESE]  child_process.fork和cluster.fork之间有什么有效的区别?


I understand that cluster.fork will allow for multiple processes to listen on the same port(s), what I also want to know is how much additional overhead is there in supporting this when some of your workers are not listeners/handlers for the tcp service?

我知道cluster.fork将允许多个进程监听相同的端口,我还想知道当你的一些工作人员不是tcp的监听器/处理程序时,支持这个的额外开销是多少服务?

I have a service that I also want to launch a couple of workers.. ex: 2 web service listener processes, and 3 worker instances. Is it best to use cluster for them all, or would cluster for the 2 web services, and child_process for the workers be better?

我有一个服务,我也想发起几个工人..例如:2个Web服务监听器进程和3个工作器实例。最好是为所有人使用集群,还是为2个Web服务集群,而对于工作者的child_process会更好?

I don't know the internals in node, but think it would be nice for myself and others to have a better understanding of which route to take given different needs. For now, I'm using cluster for all the processes.

我不知道节点中的内部结构,但认为对于我自己和其他人来说,更好地了解根据不同的需求采取哪种路线会很好。现在,我正在为所有进程使用集群。

1 个解决方案

#1


11  

cluser.fork is implemented on top of child_process.fork. The extra stuff that cluster.fork brings is that, it will enable you to listen on a shared port. If you don't want it, just use child_process.fork. So yeah, use cluster for web servers and child_process for workers.

cluser.fork是在child_process.fork之上实现的。 cluster.fork带来的额外功能是,它可以让你在共享端口上侦听。如果你不想要它,只需使用child_process.fork。所以,是的,使用集群用于Web服务器,使用child_process用于工作者。


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2018 ITdaan.com 粤ICP备14056181号