Loading time of child process

52 views
Skip to first unread message

Vinay Ram

unread,
Jun 4, 2014, 11:30:30 PM6/4/14
to nod...@googlegroups.com
I have a scenario where multiple node apps must be executed in embedded environment. Loading time is one of the crucial factor and I am wondering if running the apps in separate child processes (using child_process.fork) is faster than running them in independent node processes. Any ideas? 

A related question. Does child_process.fork() use copy-on-write?

greelgorke

unread,
Jun 5, 2014, 3:15:30 AM6/5/14
to nod...@googlegroups.com
child_process.fork creates a new node.js process with this specifcs: "These child Nodes are still whole new instances of V8. Assume at least 30ms startup and 10mb memory for each new Node. " from here: http://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options. they are no threads. so in the embedded environment i'd look for a solution without many forks.

witch loading time being critical i'd got for creating all nodes on startup once and let them act as services.

Forrest Norvell

unread,
Jun 5, 2014, 4:42:52 AM6/5/14
to nod...@googlegroups.com
On Wed, Jun 4, 2014 at 8:30 PM, Vinay Ram <vina...@gmail.com> wrote:
I have a scenario where multiple node apps must be executed in embedded environment. Loading time is one of the crucial factor and I am wondering if running the apps in separate child processes (using child_process.fork) is faster than running them in independent node processes. Any ideas? 

If you use `child_process`, you'll have an IPC channel between the controlling and child processes that may save you a little bit of marshaling overhead, but either way you're going to end up with multiple processes. You're likely to get more time savings by starting all of your processes ahead of time, if you know how many you're going to need and you have enough RAM to keep them all in memory.
 
A related question. Does child_process.fork() use copy-on-write?

No. CoW wouldn't get you that much, either, due to V8 being a JITted dynamic runtime; you might be able to share the core V8 code, but none of the JS pages. CoW and dynamic languages don't really get along.
Reply all
Reply to author
Forward
0 new messages