Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Erlang, is it possible to send a running process to a different node?

I have been researching Mobile Agents, and was wondering if it is possible to send a running process to another node in erlang. I know it is possible to send a process on another node a message. I know it is possible to load a module on all nodes in a cluster. Is it possible to move a process that might be in some state on a particular node to another node and resume it's state. That is, does erlang provide strong mobility? Or is it possible to provide strong mobility in erlang?

like image 421
Matthew Sowders Avatar asked Feb 27 '11 20:02

Matthew Sowders


People also ask

Which function is used to send the message to another node?

send() Method. The socket. send() method is an inbuilt application programming interface of class Socket within dgram module which is used to send the message from one socket to another socket.

How do Erlang nodes communicate?

Authentication determines which nodes are allowed to communicate with each other. In a network of different Erlang nodes, it is built into the system at the lowest possible level. All nodes use a magic cookie, which is an Erlang atom, when connecting another node.

How do you spawn a process in Erlang?

Erlang Language Processes Creating Processes You can also use spawn/3 to start a process that will execute a specific function from a module: spawn(Module, Function, Args) . Or use spawn/2 or spawn/4 similarly to start a process in a different node: spawn(Node, Fun) or spawn(Node, Module, Function, Args) .

What is PID in Erlang?

Each process in erlang has a process identifier ( Pid ) in this format <x.x.x> , x being a natural number. Below is an example of a Pid <0.1252.0> Pid can be used to send messages to the process using 'bang' ( ! ), also Pid can be bounded to a variable, both are shown below. MyProcessId = self().


1 Answers

Yes, it is possible, but there is no "Move process to node" call. However, if the process is built with a feature for migration, you can certainly do it by sending the function of the process and its state to another node and arrange for a spawn there. To get the identity of the process right, you will need to use either the global process registry or gproc, as the process will change pid.

There are other considerations as well: The process might be using an ETS table whose data are not present on the other node, or it may have stored stuff in the process dictionary (state from the random module comes to mind).


The general consensus in Erlang is that processes are not mobilized to move between machines. Rather, one either arranges for a takeover of applications between nodes should a node die. Or for distribution of the system so data are already distributed to another machine. In any case, the main problem of making state persistent in the event of errors still hold, mobility or not - and distribution is a nice tool to solve the persistence problem.

like image 157
I GIVE CRAP ANSWERS Avatar answered Oct 14 '22 16:10

I GIVE CRAP ANSWERS