Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
The Most Efficiency Method Inter-Process-Communication
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  23 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
JustinSD  
View profile  
 More options Apr 27 2011, 3:14 pm
From: JustinSD <jkel...@fieldtechnologies.com>
Date: Wed, 27 Apr 2011 12:14:04 -0700 (PDT)
Local: Wed, Apr 27 2011 3:14 pm
Subject: The Most Efficiency Method Inter-Process-Communication
We are doing inter-process communication between two node.js
applications. We initially have it setup via a simple TCP socket, but
wondering if we should switch to a named pipe (FIFO) for performance
reasons. Is this even possible in node? Basically, what is the most
efficient, and fastest way to do IPC between two node.js applications
on the same physical server?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Caswell  
View profile  
 More options Apr 27 2011, 3:22 pm
From: Tim Caswell <t...@creationix.com>
Date: Wed, 27 Apr 2011 12:22:01 -0700
Local: Wed, Apr 27 2011 3:22 pm
Subject: Re: [nodejs] The Most Efficiency Method Inter-Process-Communication

It's been my experience that the bottleneck is the serialization and
de-serialization of the data, not the actual channel.  I'm pretty sure you
can use named pipes, but I'm not sure what the API is.  msgpack seems like a
good format for the data interchange.  There are a few libraries out there
that implement msgpack or ipc frameworks on top of it.

On Wed, Apr 27, 2011 at 12:14 PM, JustinSD <jkel...@fieldtechnologies.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge  
View profile  
 More options Apr 27 2011, 6:45 pm
From: Jorge <jo...@jorgechamorro.com>
Date: Thu, 28 Apr 2011 00:45:52 +0200
Local: Wed, Apr 27 2011 6:45 pm
Subject: Re: [nodejs] The Most Efficiency Method Inter-Process-Communication
On 27/04/2011, at 21:14, JustinSD wrote:

> We are doing inter-process communication between two node.js
> applications. We initially have it setup via a simple TCP socket, but
> wondering if we should switch to a named pipe (FIFO) for performance
> reasons. Is this even possible in node? Basically, what is the most
> efficient, and fastest way to do IPC between two node.js applications
> on the same physical server?

Interesting question, where's a benchmark ?
--
Jorge.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
billywhizz  
View profile  
 More options Apr 27 2011, 6:56 pm
From: billywhizz <apjohn...@gmail.com>
Date: Wed, 27 Apr 2011 15:56:28 -0700 (PDT)
Local: Wed, Apr 27 2011 6:56 pm
Subject: Re: The Most Efficiency Method Inter-Process-Communication
you should get better performance/throughput from a unix socket as you
won't be going through the network stack at all. as far as i know
mkfifo doesn't have a binding in node.js so you'll have to do some c++
hackery to get fifo's working. stdin/stdout should also be very fast
but will do the job if you are just connecting two applications
together...

if you really want to you could use a memory mapped file (https://
github.com/bnoordhuis/node-mmap), but then you'll have to worry about
multiple readers/writers and will most likely have to do some kind of
locking, which is pretty much against the whole node.js ethos.

Tim is correct. JSON.parse and JSON.stringify suck really bad. You'll
have to roll your own serialization if you want real performance.
msgpack is good, but it's a generic solution and is doing a lot of
extra work because it has to handle any type of message. would be
fastest if the wire format is know in advance and you write a custom
parser. you'll have to do your own testing on whether to do the
parsing in js (working with binary is slow) or c/c++ (much faster but
you will be penalised every time you make a call into the external
library so you should probably be buffering data and doing as few
calls as possible).

On Apr 27, 8:14 pm, JustinSD <jkel...@fieldtechnologies.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bert Belder  
View profile  
 More options Apr 27 2011, 6:57 pm
From: Bert Belder <bertbel...@gmail.com>
Date: Wed, 27 Apr 2011 15:57:18 -0700 (PDT)
Local: Wed, Apr 27 2011 6:57 pm
Subject: Re: The Most Efficiency Method Inter-Process-Communication
On Apr 27, 9:14 pm, JustinSD <jkel...@fieldtechnologies.com> wrote:

> We are doing inter-process communication between two node.js
> applications. We initially have it setup via a simple TCP socket, but
> wondering if we should switch to a named pipe (FIFO) for performance
> reasons. Is this even possible in node? Basically, what is the most
> efficient, and fastest way to do IPC between two node.js applications
> on the same physical server?

You can use unix domain sockets instead of tcp streams.
Use (net.createServer()).listen("/tmp/my/socket") and
net.createConnection("/tmp/my/socket") to do that.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
billywhizz  
View profile  
 More options Apr 27 2011, 6:58 pm
From: billywhizz <apjohn...@gmail.com>
Date: Wed, 27 Apr 2011 15:58:16 -0700 (PDT)
Local: Wed, Apr 27 2011 6:58 pm
Subject: Re: The Most Efficiency Method Inter-Process-Communication
i'll try to put some benchmarks together at the weekend. i have
already benchmarked a lot of this stuff when rolling my own binary
parsers, but i don't have any nice stats to hand at the moment.

On Apr 27, 11:45 pm, Jorge <jo...@jorgechamorro.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kowsik  
View profile  
 More options Apr 27 2011, 7:23 pm
From: kowsik <kow...@gmail.com>
Date: Wed, 27 Apr 2011 16:23:37 -0700
Local: Wed, Apr 27 2011 7:23 pm
Subject: Re: [nodejs] Re: The Most Efficiency Method Inter-Process-Communication

On Wed, Apr 27, 2011 at 3:56 PM, billywhizz <apjohn...@gmail.com> wrote:
> you should get better performance/throughput from a unix socket as you
> won't be going through the network stack at all. as far as i know
> mkfifo doesn't have a binding in node.js so you'll have to do some c++
> hackery to get fifo's working. stdin/stdout should also be very fast
> but will do the job if you are just connecting two applications
> together...

Hmm, not necessarily. My experience with unix sockets is that you
don't get the same level of kernel tuning that you do with TCP (listen
backlog, max send/recv buffer size, etc). See this blog that talks
about FastCGI which does use unix/sockets. We ran into all sorts of
bottlenecks.

http://labs.mudynamics.com/2011/03/30/blitzio-the-long-night-before-a...

stdin/stdout will be no-go as well since you are queueing up all of
the messages into a single fd-pair and will result in pipeline stall.
This is similar to using a single HTTP node client to talk to CouchDB,
which ends up queuing up all of the requests. Bad from a concurrency
standpoint.

K.
---
http://blitz.io
http://twitter.com/pcapr
http://labs.mudynamics.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt  
View profile  
 More options Apr 27 2011, 7:58 pm
From: Matt <hel...@gmail.com>
Date: Wed, 27 Apr 2011 19:58:51 -0400
Local: Wed, Apr 27 2011 7:58 pm
Subject: Re: [nodejs] Re: The Most Efficiency Method Inter-Process-Communication

Not only that, but TCP over localhost is directly optimised (on Linux at
least) and is as fast as unix domain sockets (uses the same code IIRC). It
doesn't hit the network stack any (since about 10+ years ago).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
billywhizz  
View profile  
 More options Apr 27 2011, 8:00 pm
From: billywhizz <apjohn...@gmail.com>
Date: Wed, 27 Apr 2011 17:00:35 -0700 (PDT)
Local: Wed, Apr 27 2011 8:00 pm
Subject: Re: The Most Efficiency Method Inter-Process-Communication
my bad. i was under the impression that stdio was full duplex.

had a look at that article. the problem they were having was because
they were setting the backlog too small. you would be getting dropped
packets and connection refused errors just the same if you had done
the same thing with TCP. i find it hard to believe you could make TCP
as fast as a unix socket considering TCP has to go through the network
stack and TCP has all the packet overhead too... W Richard Stevens
says unix domain sockets are more efficient than network sockets and
that's usually good enough for me. ;)

Unix domain sockets also allow you to use datagrams rather than
streams, which might be good depending on what your requirements are.
The datagrams are reliable and in-order over a unix socket though, not
like in UDP.

On Apr 28, 12:23 am, kowsik <kow...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dean Mao  
View profile  
 More options Apr 27 2011, 8:16 pm
From: Dean Mao <dean...@gmail.com>
Date: Wed, 27 Apr 2011 17:16:05 -0700
Local: Wed, Apr 27 2011 8:16 pm
Subject: Re: [nodejs] The Most Efficiency Method Inter-Process-Communication

We have a lib called redpack that we're using:
https://github.com/luxdelux/redpack

It is based partly on msgpack-rpc and previously used msgpack for
serialization, but was switched to bson because msgpack was not very good
for cross-language type conversions.  It supports sync & async rpc for node,
java, and ruby, but requires you to have redis.  It's basically a very
simple message queue rpc.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
billywhizz  
View profile  
 More options Apr 27 2011, 8:19 pm
From: billywhizz <apjohn...@gmail.com>
Date: Wed, 27 Apr 2011 17:19:14 -0700 (PDT)
Local: Wed, Apr 27 2011 8:19 pm
Subject: Re: The Most Efficiency Method Inter-Process-Communication
does TCP over loopback on linux really not hit the network stack?
doesn't it do packet framing, checksums and protocol handshakes etc? i
can't find any reference to this, so if you have one, please let me
know.

i'm going to do a benchmark in node.js anyway to see what the
difference is. it will probably be negligible considering the overhead
in node.js and v8 anyway.

what do you think would be best for a benchmark? two node.js process
communicating with each other with varying message sizes and numbers
of connections? could also benchmark the different serialization
methods too which would be useful. JSON v msgpack v js custom parser v
c++ custom parser. i have a lot of code to do this already so wouldn't
be a huge amount of work...

On Apr 28, 12:58 am, Matt <hel...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kowsik  
View profile  
 More options Apr 27 2011, 8:32 pm
From: kowsik <kow...@gmail.com>
Date: Wed, 27 Apr 2011 17:32:08 -0700
Local: Wed, Apr 27 2011 8:32 pm
Subject: Re: [nodejs] Re: The Most Efficiency Method Inter-Process-Communication

On Wed, Apr 27, 2011 at 5:00 PM, billywhizz <apjohn...@gmail.com> wrote:
> my bad. i was under the impression that stdio was full duplex.

Full duplex is not the same as concurrent. Each TCP connection is
full-duplex, but in order to achieve concurrency, you need multiple
connections.

> had a look at that article. the problem they were having was because
> they were setting the backlog too small. you would be getting dropped
> packets and connection refused errors just the same if you had done
> the same thing with TCP. i find it hard to believe you could make TCP
> as fast as a unix socket considering TCP has to go through the network
> stack and TCP has all the packet overhead too... W Richard Stevens
> says unix domain sockets are more efficient than network sockets and
> that's usually good enough for me. ;)

> Unix domain sockets also allow you to use datagrams rather than
> streams, which might be good depending on what your requirements are.
> The datagrams are reliable and in-order over a unix socket though, not
> like in UDP.

There's a possibility that the datagram unix sockets are faster, but
then you would have to account for the loss of messages in case of
buffer shortage. If you explore sysctl, there isn't much to tune for
unix sockets, but there are a bazillion options for TCP.

K.
---
http://blitz.io
http://twitter.com/pcapr
http://labs.mudynamics.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt  
View profile  
 More options Apr 27 2011, 8:44 pm
From: Matt <hel...@gmail.com>
Date: Wed, 27 Apr 2011 20:44:58 -0400
Local: Wed, Apr 27 2011 8:44 pm
Subject: Re: [nodejs] Re: The Most Efficiency Method Inter-Process-Communication

On Wed, Apr 27, 2011 at 8:19 PM, billywhizz <apjohn...@gmail.com> wrote:
> does TCP over loopback on linux really not hit the network stack?
> doesn't it do packet framing, checksums and protocol handshakes etc? i
> can't find any reference to this, so if you have one, please let me
> know.

AFAIK it's optimised to not go through the network driver layer (so it still
goes through parts of the stack, but is optimised so that it doesn't have to
talk to hardware). But this is just a memory from when I used to read the
Kernel change logs years and years ago.  I can't find any reference to it
online now.

Matt.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
billywhizz  
View profile  
 More options Apr 27 2011, 9:30 pm
From: billywhizz <apjohn...@gmail.com>
Date: Wed, 27 Apr 2011 18:30:52 -0700 (PDT)
Local: Wed, Apr 27 2011 9:30 pm
Subject: Re: The Most Efficiency Method Inter-Process-Communication
Thanks Matt. had a google but there doesn't seem to be much definitive
info out there. i'd wager for large message sizes a unix socket should
be quite a bit faster but if sending lots of small messages, you
probably won't see a whole lot of difference.

Justin, the best way to answer a question like this is to do the
testing yourself based on the system/environment you are optimizing
for. There's no way to give a definitive general answer to your
question.

anyway, i'll see what kind of benchmark i can throw together - i'm
more interested in the cost of serialization differences myself.

On Apr 28, 1:44 am, Matt <hel...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aikar  
View profile  
 More options Apr 27 2011, 10:42 pm
From: Aikar <xdr...@gmail.com>
Date: Wed, 27 Apr 2011 19:42:12 -0700 (PDT)
Local: Wed, Apr 27 2011 10:42 pm
Subject: Re: The Most Efficiency Method Inter-Process-Communication
Just throwing in my recent findings,
V8 has apparently done a massive performance boost on JSON.

msgpack is now alot slower than JSON

see: https://github.com/aikar/wormhole/issues/3

I had a good streaming msgpack parser implemented doing 50k messages/
sec, and switching to json tripled the speed.

On Apr 27, 9:30 pm, billywhizz <apjohn...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
billywhizz  
View profile  
 More options Apr 27 2011, 11:43 pm
From: billywhizz <apjohn...@gmail.com>
Date: Wed, 27 Apr 2011 20:43:24 -0700 (PDT)
Local: Wed, Apr 27 2011 11:43 pm
Subject: Re: The Most Efficiency Method Inter-Process-Communication
interesting. i am seeing the same speedup. the benchmark on msgpack
github is way out of date. i tested here using an old 0.1.96 version
of node versus latest 0.4.7 on 64 bit with v8 v3.1.8.10 and saw the
following results for peter's bench.js script (i just ran the JSON
tests not the msgpack ones):

v0.1.96:
json    pack:   6787 ms
json    unpack: 11888 ms

v0.4.7:
json    pack:   1487 ms
json    unpack: 851 ms

That's almost 8x faster for JSON.stringify and almost 14x faster for
JSON.parse. This is very nice indeed!

On Apr 28, 3:42 am, Aikar <xdr...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris  
View profile  
 More options Apr 28 2011, 12:02 am
From: Chris <cohar...@gmail.com>
Date: Wed, 27 Apr 2011 21:02:14 -0700 (PDT)
Local: Thurs, Apr 28 2011 12:02 am
Subject: Re: The Most Efficiency Method Inter-Process-Communication
I use a modified version of kriszyp's multi-node that enables 2-way
communication

Source is here:
https://github.com/chriso/node.io/blob/master/lib/node.io/multi_node.js

You set it up like this:
https://github.com/chriso/node.io/blob/master/lib/node.io/processor.j...

Then just use `master.send(msg)` or `workers[i].send(msg)`

It's been more than fast enough.

On Apr 28, 1:43 pm, billywhizz <apjohn...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
billywhizz  
View profile  
 More options Apr 28 2011, 12:46 am
From: billywhizz <apjohn...@gmail.com>
Date: Wed, 27 Apr 2011 21:46:35 -0700 (PDT)
Local: Thurs, Apr 28 2011 12:46 am
Subject: Re: The Most Efficiency Method Inter-Process-Communication
btw - i should have said i am running node v0.4.6 above...

On Apr 28, 5:02 am, Chris <cohar...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
billywhizz  
View profile  
 More options Apr 28 2011, 12:54 am
From: billywhizz <apjohn...@gmail.com>
Date: Wed, 27 Apr 2011 21:54:05 -0700 (PDT)
Local: Thurs, Apr 28 2011 12:54 am
Subject: Re: The Most Efficiency Method Inter-Process-Communication
interestingly, node v0.4.6 built with v8 3.3.2 which should have
crankshaft enabled on 64 bit is slightly quicker for stringify and
quite a bit slower for parse:

node 0.4.6/v8 3.3.2
json    pack:   1318 ms
json    unpack: 1039 ms

node.0.4.6/v8 3.1.8.10
json    pack:   1487 ms
json    unpack: 851 ms

On Apr 28, 5:02 am, Chris <cohar...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris  
View profile  
 More options Apr 28 2011, 8:32 am
From: Chris <cohar...@gmail.com>
Date: Thu, 28 Apr 2011 05:32:49 -0700 (PDT)
Local: Thurs, Apr 28 2011 8:32 am
Subject: Re: The Most Efficiency Method Inter-Process-Communication
How does a straight `eval(json)` compare to `JSON.parse(json)` for
unpacking?

On Apr 28, 2:54 pm, billywhizz <apjohn...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aikar  
View profile  
 More options Apr 28 2011, 8:47 am
From: Aikar <xdr...@gmail.com>
Date: Thu, 28 Apr 2011 05:47:04 -0700 (PDT)
Local: Thurs, Apr 28 2011 8:47 am
Subject: Re: The Most Efficiency Method Inter-Process-Communication
Justin/OP:
You can try my Wormhole lib.
https://github.com/aikar/wormhole

It's designed to simply pass it ends of a stream, and it just works.

As said in benchmark above, I've got it up to 150k messages processed
per second on a single 3.4ghz core.
And that was just 1 core feeding it, so sending would of bottlenecked
it, if you had multiple processes sending it data, im sure it would
get even faster

On Apr 28, 8:32 am, Chris <cohar...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bgsosh  
View profile  
 More options Sep 21 2012, 12:22 pm
From: Bgsosh <bgs...@gmail.com>
Date: Fri, 21 Sep 2012 09:22:05 -0700 (PDT)
Local: Fri, Sep 21 2012 12:22 pm
Subject: Re: The Most Efficiency Method Inter-Process-Communication

Just to let you all know that there is a Stackoverflow question on this
issue, in case you wanted to air your views there:

http://stackoverflow.com/questions/6463945/whats-the-most-efficient-n...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yi  
View profile  
 More options Sep 29 2012, 3:52 am
From: Yi <yi2...@gmail.com>
Date: Sat, 29 Sep 2012 00:52:13 -0700 (PDT)
Local: Sat, Sep 29 2012 3:52 am
Subject: Re: [nodejs] Re: The Most Efficiency Method Inter-Process-Communication

we are using UPD datagram for cross-process communication of node apps on
the same machine. The performance is incredible.
here is the code repo:
https://github.com/SGF-Games/node-udpcomm

regards,

ty

在 2011年4月28日星期四UTC+8上午8时32分08秒,kowsik写道:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »