[erlang-questions] [99s-extend] How to broadcaset with ranch?

Michael Truog <>
Wed Aug 21 19:29:28 CEST 2013

On 08/21/2013 10:04 AM, David Mercer wrote:
> On Tuesday, August 20, 2013, Andrew Thompson wrote:
>> On Tue, Aug 20, 2013 at 10:18:19PM -0500, Sean Cribbs wrote:
>>> This is exactly the sort of thing gen_event is for. I would make each
>>> server process register a handler at startup using
>>> gen_event:add_sup_handler() and then have the handle_event callback
>>> simply relay the event to the server processes. Yes, gproc can do
>>> this, but why incur its extra features and overhead?
>> pg2 also works fairly well.
> Can someone summarize the advantages/disadvantages of each: gproc, gen_event, and pg2?
> Cheers,
> _______________________________________________
> erlang-questions mailing list
> http://erlang.org/mailman/listinfo/erlang-questions

gproc uses gen_leader for a CA-type (from CAP theorem) process lookup that has trouble with partition tolerance due to usage of gen_leader
gen_event is just an OTP behaviour, so it would be using the normal process registration to create a single process instance
pg2 is a AP-type (from CAP theorem) process lookup

you can use gproc with gen_event, if you choose, using the "via" name registration to rely on an external module
pg2 doesn't support the via name registration, however, a similar process group installation (similar to pg2) is in cpg (https://github.com/okeuday/cpg/) which does support via name registration, so you could use cpg with gen_event

So, your choice depends on whether you choose to use distributed erlang, and if you do choose to use distributed erlang, whether you care about partition tolerance or whether you care about consistency.

More information about the erlang-questions mailing list