[erlang-questions] sync gproc table with a slave server

pablo platt pablo.platt@REDACTED
Sat Dec 20 00:15:34 CET 2014


Paul, my use case is simple. I have a master server that handles user
sessions and a slave server that handles a specific app separated from the
main session.
The slave need to know if a user has permission to view or edit app
instance.
gproc local is very nice because it clean names and properties when a
process dies.

With mnesia I could use ram only table and have a read-only copy on the
slave.
I can also listen to table events and handle user permissions changes.

Another option is that the slave will make a call to the master when a new
user try to access an app instance.
When a user permission is changed on the master, it will send a message to
the slave.
This is a bit more complicated and in case of a network error, I'll might
be in a non consistent state.

If gproc had a simple read only replication (based on mnesia?) and more
granular notifications it could solve my use case.

On Sat, Dec 20, 2014 at 1:03 AM, Loïc Hoguin <essen@REDACTED> wrote:

> Guessing by erlang:rpc/3 you meant to look at the rpc module. This module
> allows both synchronous and asynchronous calls (the latter is often missed).
>
> Also look at gen_server:multi_call/2,3,4 and gen_server:abcast/2,3, and at
> equivalents for gen_fsm and others.
>
> I have had issues with gproc+gen_leader (if a node crashes, the tables
> lose sync). Ulf created the locks application that can be used with gproc,
> not sure if this gproc+locks combination works well though. Been eager to
> know and tried to get people to test it, as I haven't had the opportunity
> to try myself. :-)
>
> A gproc local + multi_call/abcast solution has worked pretty well in my
> experience, with a small number of servers located right next to each
> other. This wouldn't work with a large number of servers though.
>
> On 12/20/2014 12:47 AM, Paul Peregud wrote:
>
>> Pablo, since you have not provided that much information, I'll suggest
>> to try to get away with calls to master node's gproc app instance via
>> Erlang distribution (erlang:rpc/3). You will avoid a can of worms.
>>
>> Or you can try gproc global registration. I would suspect dragons in
>> that particular area.
>>
>> On Dec 18, 2014 7:48 PM, "pablo platt" <pablo.platt@REDACTED
>> <mailto:pablo.platt@REDACTED>> wrote:
>>
>>     Hi,
>>
>>     I'm using gproc to register user sessions.
>>     How can I sync the gproc ets table with a slave server?
>>     Is gen_leader an overkill when the same server will always be the
>>     master and I don't need master election?
>>
>>     Can the slave be notified for any change in gproc so it will know
>>     when a user session added, removed or changed?
>>
>>     Thanks
>>
>>     _______________________________________________
>>     erlang-questions mailing list
>>     erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>>     http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
> --
> Loïc Hoguin
> http://ninenines.eu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141220/387be045/attachment.htm>


More information about the erlang-questions mailing list