0

What algorithm or design pattern does Erlang use internally to guarantee a unique pid across multiple nodes? And also what algorithm or design pattern does Erlang use for keeping the global node names mapping synchronized between all the nodes?

The purpose of this question is to create similar behavior in a distributed C#.Net application. The C#.Net system already has high performance, parallel messaging and task scheduling algorithm very similar to Erlang for parallel processing on multiple cores.

The goal now is to extend it to send and receive messages to and from multiple nodes on different machines.

One simple solution will be to make it "client & server" so that only one of the nodes is the "master" for keeping the unique PID and global names of nodes.

But it's a seductive design to have the data replicated between all the nodes so that a network lookup can be avoided every time to check the actual location of a named node, since it might fail over to another machine.

It will be far more efficient for each message passed if any changes to the node name table are replicated to all the nodes like in Erlang.

Plus, what if the "master" node fails? So a distributed, replicated, and synchronized solution is a better design.

Can anyone direct an understanding of how Erlang does this under the covers?

Wayne
  • 2,959
  • 3
  • 30
  • 48

1 Answers1

0

As was answered in the comments, how a PID is kept unique is explained here: Can someone explain the structure of a Pid in Erlang? (spoiler: it's actually not a 'globally' unique id).

Regarding the global table for named processes: In distributed Erlang this is managed by the global module, which provides a Global Name Registration Facility. The registry data is replicated between the nodes, and registration is atomic.

Nodes are loosely connected in distributed Erlang. Meaning there is no global view of the cluster which needs to be synchronised.

Also, Erlang is more about concurrency then parallelism. A good explanation of the concurrency model of Erlang (and the difference with parallelism) can be found here.

Community
  • 1
  • 1
Ward Bekker
  • 6,316
  • 9
  • 38
  • 61