Implementing Child Forks
Node.js provides a specialized form of process spawning called a fork, which is designed to execute Node.js module code inside another V8 instance running on a separate processor. You can use a fork to run multiple services in parallel. However, it takes time to spin up a new instance of V8, and each instance takes about 10MB of memory. Therefore, you should design forked processes to be longer lived, and you shouldn’t require a large number of them. Remember that you really don’t get a performance benefit from creating more processes than you have CPUs in the system.
Unlike spawn, you cannot configure stdio for the child process. Instead, you use the send() mechanism in the ChildProcess object to communicate between ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access