2

We have a node.js processes that are forking other node.js processes via child_process.fork - on the same host. Communication between child and parent is done over child.send(message).

Now we want the master process to start not only node.js but also Java process. What do you think shall be the best way to communicate between Java and master node.js process on the same host?

Renat
  • 263
  • 3
  • 13

2 Answers2

0

There are a lot of those "under an hour" options you can explore.

Some suitable mediums that are accessible both to Node.js and Java would include D-Bus, Network sockets, WebSockets, Redis publish/subscribe and etcd, but it ultimately depends on your platform/communication/application requirements (i.e. etcd is suitable for service discovery and configuration sharing, but not for general-purpose communication).

Filip Dupanović
  • 32,650
  • 13
  • 84
  • 114
  • 1
    Thanks for the reply, options you mentioned are definitely very interesting, but it just feels wrong for me to use network when we are communicating with the processes on the same host. Any other options for e.g. filesystem? – Renat Jul 14 '14 at 09:33
  • D-Bus is the fastest and most elegant IPC option you have, but it is not cross-platform. Other options that rely on networking will outperform, in terms of I/O throughoutput, anything you use that relies on performing disk I/O. I do not understand what is the problem to use network-bound I/O on the same host, i.e. TCP/IP with Redis on the same host is so fast that it will add very little latency to other tasks your processes are performing and it's applicable as a communication medium for 99% of infrastructures out there. – Filip Dupanović Jul 14 '14 at 21:40
0

You can also use the stdin property of the child process that you spawned -

Nodejs Child Process: write to stdin from an already initialised process

And read from it in your child process like so -

https://nodejs.org/api/process.html#process_process_stdin

Community
  • 1
  • 1
surtyaar
  • 2,532
  • 1
  • 18
  • 13