[erlang-questions] pg2 vs gproc?
Wed Jun 6 19:03:01 CEST 2012
This is true. I prefer to recommend people to use gproc as a mainly local registry. Of course, just as with the built-in registry, using it doesn't limit your system to running on one node. It's just that the registry is local to each node. ;-)
The newest versions of gen_leader are supposedly more tolerant to netsplits, but no facility to merge the user-level data exists (esp. not in gproc). In this regard, mnesia is much better off, since there are ways to deal with netsplits and recover to a consistent state (even though those ways may not appeal to everyone).
Of course, as long as this issue remains, one should at least think twice before relying on global registration in gproc. It can still work, as long as there are system-level recovery measures after netsplits that also fix gproc (e.g. the system detects the problem, identifies a consistent island, and restarts all other nodes).
On 6 Jun 2012, at 18:44, Michael Truog wrote:
> The other differences are mentioned in previous email threads. pg2 replicates all name lookup information in a way that doesn't require consistency (it does use ets though, if you don't want to use ets, there is an example herehttps://raw.github.com/okeuday/CloudI/master/src/lib/cloudi/src/list_pg.erl). gproc uses gen_leader so it maintains a central name lookup authority. So, pg2 is AP from the CAP theorem, while gproc is CA. That means gproc has issues with partition tolerance, similar to mnesia. To me, gproc is a method by which you are able to introduce global variables into your Erlang program. This helps beginners that are not working on large codebases, but it is generally only for Erlang that is limited to a single node. An implementation of gen_leader behavior that is suppose to have better partition tolerance is here https://github.com/ngmoco/gl_async_bully , but I don't know the details. I don't see leader election as necessary in Erlang, though it is a
> fun intellectual exercise.
Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
More information about the erlang-questions