cluster.fork之间的childprocess.fork有什么区别

简单的问题:与cluster.fork之间的child_process.fork有什么区别

详情:

  1. 我可以将parameter passing给cluster.fork

  2. 我可以在同一个端口或unixsock上侦听child_process.fork创build的ChildProcess

阅读文档: child_process.fork vs cluster.fork

cluster.fork()child_process.fork()之间的区别在于,群集允许在工作人员之间共享TCP服务器。 cluster.fork是在child_process.fork之上实现的。

http://nodejs.org/api/cluster.html


我可以将parameter passing给cluster.fork

不是根据文档,和:

 > var cluster = require('cluster') undefined > cluster { isWorker: false, isMaster: true, fork: [Function], _startWorker: [Function], _getServer: [Function] } > cluster.fork.length 0 

( 函数的length是forms参数的数量)。 使用消息传递 。

2.我可以在同一个端口或unixsock监听childProcess.fork创build的ChildProcess

大概是的,因为cluster.fork是在child_process.fork之上实现的。 但是,如果要在同一个端口上侦听,则cluster.fork已存在。