| Start |
|---|
| Cluster The Clustering is desirable when the different instances have the same flow of execution and don't depend on one another. In this scenario, you have one master that can start forks and the forks (or children). The children work independently and have their one space of Ram and Event Loop. Setting up clusters can be beneficial for websites / APIs. Any thread can serve any customer, as it doesn't depend on other threads. A Database (like Redis) would be used to share Cookies, as variables can't be shared! between the threads. |
| Child Process Child Processes are the way to go when one wants to run processes independently with different initialization and concerns. Like forks in clusters, a The communication goes both ways, so parent and child can listen for messages and send messages. Parent (../parent.js) Child (../child.js) Next to message one can listen to many events (opens new window) like 'error', 'connected' or 'disconnect'. Starting a child process has a certain cost associated with it. One would want to spawn as few of them as possible. RemarksUnderstanding the Event Loop (opens new window) is important to understand how and why to use multiple threads. |
Read Article
https://develop.horje.com/learn/1434/reference