Erlang/OTP Forums

Author Message

<  Open Telecom Platform (OTP)  ~  Supervision tree spawning gen_servers on remote nodes?

lflemmer
Posted: Sun Nov 04, 2007 12:24 am Reply with quote
Joined: 04 Nov 2007 Posts: 1 Location: New York
I am new to OTP programming, and I am trying to understand the appropriate idiom for what seems like a common task.

I want to create a system to do distributed computation, i.e. I will have worker processes running on nodes on different hosts. I want to bring up all these various processes at the same time, and have them be robust (restart if they fail etc).

My first inclination is to create a supervision tree, in which each of the distributed nodes is a gen_server. However, it is not clear to me how to do this while staying within the common pattern of the gen_server behaviour. gen_server:start_link/4 doesn't do it, since I have no way to specify that the MFA should spawn on a remote node. I could achieve what I want if gen_server exposed a spawn_link function, but it doesn't.

Obviously I can roll my own management of the distributed nodes using the BIFs, but I was hoping to do it within the OTP paradigm.

Any pointers on how to achieve this, or an explanation of what a more appropiate OTP idiom is would be much appreciated.
View user's profile Send private message
admin
Posted: Mon Nov 05, 2007 8:20 am Reply with quote
Site Admin Joined: 28 Jun 2006 Posts: 108
What you want to do is have a supervisor on the remote node which supervises the child locally. If node A needs a child started on node B, send a message to a process on node B which will do it for you. This can easily be done with the supervisor:start_child/2 call, where the first argument to the function might be a supervisor on a remote node.

In large distributed systems, your biggest enemy will be the network and firewalls, which will create occasional blips. Linking processes across nodes is not advised.

Hope this helps,
Francesco
--
http://www.erlang-consulting.com
View user's profile Send private message

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 can attach files in this forum
You can download files in this forum