views:

436

answers:

2

I need an answer to the following question to help understand what approach I should be taking to interface with Erlang. AFAIK Erlang on a SMP UNIX box uses the multi-process approach. In this case it should do same machine IPC.

  1. Does Erlang use UNIX domain sockets for UNIX ?
  2. Does it use named-pipes for windows ?

  3. If it does not implement both constructs above -- i.e., no named-pipes for windows; it must have to fallback to sockets, on windows.

  4. How are the above mentioned principles implemented, do they use message oriented, single-thread per channel, asynchronous constructs or is it something else ?

  5. If my line of reasoning above is incorrect, does it use a master-child tree and all other processes communicate -- indirectly -- through the master ?

-- edit 1 --

Link to the erlang binary format documentation.

The universal concensus is that Unix Domain Sockets outperform TCP/IP. I think I will try to extend Erlang to use the better primitives provided. I also strongly suspect that epol and windows IOPC is not used in the TCP/IP event loop -- I will post back once I have audited the code.

Another SO post that asserts that Erlang indeed, does not support anything other than TCP and UDP.

There are two Erlang libraries for communication Erlang node -> c_node and c_node -> Erlang_node

The Erlang module for sockets allows Unix Dom Sockets to be opened under UNIX.

A: 

R1. It uses TCP/IP (in fact, there isn't any "standard" support for UNIX domain sockets)

R2. I am pretty sure it is still TCP/IP sockets

R3. see R2

R4. There is a binary exchange format proper to Erlang and it is message based. Exchanges can either be sync (RPC-like) or async.

R5. No master.


As bonus (to help you save time): don't forget to use a registered name (-sname or -name) in order to use inter-node communications (either RPC or whatever).

jldupont
Perhaps I'm misreading the question, but it's hard to believe Erlang schedulers communicate via TCP/IP.
Zed
@zed, yes it is hard to believe. I've seen many sub-optimal IPC implementations in my review of open source stuff. The BSD TCP/IP and select() is pretty much the standard a lot of people program against. I would appreciate a link to a source file, or reference manual about the schedulers, that is if you find any.
Hassan Syed
Guys - maybe I've read the question with tinted glasses: I was assuming IPC **between** nodes (in the Erlang sense) because if we are talking about **intra-node IPC**, then of course I am pretty certain it is **not** over TCP/IP.
jldupont
Erlang does support a module for sockets, which does allow [`AF_UNIX`][1] sockets to be opened (only for unix ofcourse). this makes it possible for the scheduler to pick AF_UNIX on UNIX and default to TCP/IP on windows.[1]: http://www3.erlang.org/documentation/doc-4.8.1/pdf/sockets-1.0.5.pdf
Hassan Syed
p.s. The schedular is probably written in C. I am assuming because the scheduler is being discussed that it is running in a seperate scheduler master process ? Shouldn't each node have its own scheduler ? And why do schedulers talk to each other, are we talking about the same machine transparent message passing that goes on between nodes on the same machine?
Hassan Syed
Each node does have its own scheduler. I do not know why we are discussing schedulers here either.
jldupont
[Explains][1] the SMP model used by Erlang, it uses a single-process multi-thread model. Local IPC from the perspective of the scheduler is therefore a non-issue.[1]: http://www.erlang.org/euc/08/euc_smp.pdf
Hassan Syed
+8  A: 

As a comment to your original question and to some of the comments:

  • I am VERY sure, in fact I KNOW, that internally within a node the Erlang VM does not use sockets or pipes for communication between (Erlang) processes. That would be ludicrous and completely go against the basic Erlang principles of light-weight inter- (Erlang) process communication.

  • Between Erlang nodes the Erlang VM uses TCP/IP. The semantics and behaviour as seen from Erlang are the same as for intra-node communication, in most respects it is completely transparent on which nodes the processes involved lie.

  • SMPs don't change these basics, irrespective of how many cores and schedulers are used, and irrespective of how many schedulers are run per core.

rvirding
More detail about how Erlang's within node message passing system works: http://stackoverflow.com/questions/3391274/how-does-erlang-pass-messages-between-processes-on-the-same-node/3397945#3397945
mjs