[erlang-questions] How does gproc register global names?

Ulf Wiger <>
Tue Oct 26 17:31:24 CEST 2010


It is correct that gproc uses gen_leader.
All registration reguests are passed on to the leader process,
and it broadcasts the results to the other candidates & workers.
Monitoring of registered processes is done by the local gproc 
instance.

When a new leader is elected, it sends its list of registered names
to the others; if they happen to have names that the new leader 
doesn't know about, they will send them to the new leader.

This is not terribly unlike how global does things, although it uses
a multicall mechanism to handle atomicity. In measurements that 
I've made, the gproc method is much more efficient.

OTOH, global has facilities to handle partitioned networks. Gproc
doesn't... yet.

Using mnesia would not give better consistency, unless transactions
are used - but that would kill performance. And there are no persistency
reasons to use it either. Gproc uses ets tables, which are rigged to survive
even if the gproc process dies; the restarted gproc scans the table and 
sets new monitors.

BR,
Ulf W

On 26 Oct 2010, at 15:48, Pablo Platt wrote:

> Hi
> 
> I'm using gproc to register local names and properties.
> I've read that gen_leader is needed to use gproc in the global scope.
> 
> How does the data get synced across all nodes?
> Why isn't mnesia being used for that?
> How do you solve race conditions and failures?
> 
> Thanks
> 
> 
> 

Ulf Wiger, CTO, Erlang Solutions, Ltd.
http://erlang-solutions.com





More information about the erlang-questions mailing list