Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to make one node.js server "talk" to another?

  • MsgPack ?
  • JSON-RPC ?
  • Socket.io (is it possible ? how ?)

EDIT: I am talking about 2 node processes each one on a different physical machine;

I don't understand how redis can help me on this...

like image 925
João Pinto Jerónimo Avatar asked Feb 15 '11 23:02

João Pinto Jerónimo


People also ask

How node js is cross-platform?

Node. js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. Node. js is an open source, cross-platform runtime environment for developing server-side and networking applications.


3 Answers

I'm not really clear on whether you are looking for ways to make two node servers on two physical machines "talk to each other", or two node.js server processes on one machine.
(You could edit your question to make it clearer).

You could look at:

  • protocol buffers for node
  • MsgPack-RPC for node
  • Websocket.MQ
  • dnode --This uses socket.io as the transport layer
  • IPCNode
  • AMQP with node-amqp or node-amqp and something like RabbitMQ
  • Or you could go with a document based db like redis

Note: some of these may need some updating

I hope this helps

like image 150
Omni5cience Avatar answered Oct 05 '22 01:10

Omni5cience


I would go for redis. The pubsub semantics are pretty sweet. The node_redis client library is very fast because it can use the lightning fast c-extension-library named hiredis. I would just use json as my encoding. That will probably be more than fast enough.

You could also use DNode to do your communication if you like. I also believe it has socket.io capabilities. You should have a look at the source code to find this out.

like image 29
Alfred Avatar answered Oct 05 '22 01:10

Alfred


It is not really clear from your question what do you mean by a Node server talking to another server. You can use anything from sending UDP packets, making TCP connections, HTTP connections to using any of the high-level mechanisms that others have already pointed out.

For an interesting scenerio of Node processes communication you may take a look at the 2010 JSConf.eu talk by Mikeal Rogers. He explains how to use CouchDB to do that. Very interesting talk.

like image 42
rsp Avatar answered Oct 05 '22 03:10

rsp