Question: fork-in-fork

42 views
Skip to first unread message

Kevin Ingwersen (Ingwie Phoenix)

unread,
Apr 11, 2015, 10:46:12 PM4/11/15
to nod...@googlegroups.com
Hey.

Imagine you have the following structure:

main
* http worker#1
* http worker#2
* api worker#1

This is a structure that can easily be done with the cluster module. But what if we have one major watchdog process and the structure changes to this?

watchdog
- http server
* worker#1
* worker#2
- api server
* worker#1

This would require the watchdog process to fork() into two separate processes that it can savely watch. Then, these subprocesses would have to fork() N times for their workers.

When we now use cluster.isMaster and cluster.isChild… what behaviour could be expected from the above structure? I saw C programs doing a fork-in-fork mechanism, but not in NodeJS, especially since in this case, a script is ran again from top to bottom - and not just copied into new memory and executed at the same point, like it happens in POSIX fork() and php-pcntl pcntl_fork().

Kind regards, Ingwie

Aria Stewart

unread,
Apr 12, 2015, 3:36:26 PM4/12/15
to nod...@googlegroups.com


On Saturday, April 11, 2015 at 10:46:12 PM UTC-4, Ingwie Phoenix wrote:
When we now use cluster.isMaster and cluster.isChild… what behaviour could be expected from the above structure? I saw C programs doing a fork-in-fork mechanism, but not in NodeJS, especially since in this case, a script is ran again from top to bottom - and not just copied into new memory and executed at the same point, like it happens in POSIX fork() and php-pcntl pcntl_fork().

Sounds like those should be separate processes anyway. they don't share much or anything, not that fork is easy to get right in such a managed runtime.

One process doing one thing -- should serve you well.
Reply all
Reply to author
Forward
0 new messages