Implementing Process Clusters

One of the coolest things you can do with Node.js is create a cluster of Node.js instances running in parallel in separate processes on the same machine. You can do this using the techniques you learned in the previous section by forking processes and then using the send(message, serverHandle) IPC mechanism to communicate send() messages and pass the underlying TCP server handles between them. However, because this is such a common task, Node.js has provided the cluster module, which does all that for you automatically.


Note

At this writing, the cluster module is still in an unstable state, and therefore the syntax and available options may change from what you see in this chapter. Make sure to check the syntax against the Node.js code when you decide to implement the cluster module.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.29.151