Erlang Mailing Lists

Author Message

<  Erlang  ~  function shipping for multi-node application

bforney
Posted: Tue Oct 09, 2007 7:19 pm Reply with quote
Joined: 09 Oct 2007 Posts: 1 Location: USA
Hi,

I'd like to send a function from one module to another when the caller and callee modules are in different Erlang nodes. The caller will then store the function into a record and call the function many times. I'm concerned about performance and the ability to upgrade when doing this. Two questions:

- Does Erlang cache the function stored in the structure? Or does it ship the function across each time it is referenced?

- If Erlang stores the function on the caller's node, can an upgrade of code on either node upgrade the stored function?

Thanks,
Brian
View user's profile Send private message
francesco
Posted: Mon Oct 15, 2007 3:27 pm Reply with quote
User Joined: 07 Jul 2006 Posts: 249 Location: London
Hi Brian,

sorry for the delay in getting back to you. We are usually more prompt on TE, but have been swamped with deadlines.

Quote:
- Does Erlang cache the function stored in the structure? Or does it ship the function across each time it is referenced?


There are two ways to pass on functions. One is a tuple {Module, Function, ArgsList}. The other is a fun of the format fun() -> Module:Function(Arg1,Arg2,...,ArgN) end.

In both cases, as you are dealing with a global function call, you would ship the reference to it across once and whatever version of that module which is loaded on the remote node will be used. Checks to ensure you are running the latest version are done whenever you have a global call. So in theory, you could run one module version on one node and another version on the other.

Quote:
If Erlang stores the function on the caller's node, can an upgrade of code on either node upgrade the stored function?


You need to upgrade the code on both nodes.

Hope the above helps. If you have any questions, just post them here.

Regards,
Francesco
--
http://www.erlang-consulting.com
View user's profile Send private message Visit poster's website

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum