[erlang-questions] Distributed Process Registry
Sun Feb 8 20:56:01 CET 2015
I have 3 interconnected nodes to which various devices connect to.
Once a device connects to one of those nodes, the related TCP socket events
are handled by a device_loop process on the node that it originally
Every device is identified via its id (a binary). I need to enable
communication from one device to the other based on these ids, even within
different nodes. I have around 150k device processes per node (so up to
500k in total).
So, I basically need a global process registry. Not new, but haven't used
one in a while now.
As far as I can tell, my main options to send messages from one device
process to the other based on their id are the erlang global module, ulf's
gproc, or implement a custom solution based on, for instance, mnesia in ram
I was first thinking of leaning towards using the erlang global module,
since register_name/2,3 now also allows general terms to be used as Name.
The advantages I see:
- It is a simple built-in mechanism.
- If a node goes down, the global names registered on that node are
- If a new node is added, the global names registered are propagated
- I always feel that process registration should be used to identify
- I don't know if 500k is an acceptable number (i.e. if the global
module is made to support my use case).
I also looked into gproc. The advantages I see:
- Actively maintained, it seems to have been built for my use case.
- For the distributed part it relies on gen_leader. I've heard too many
horror stories on gen_leader. Maybe that's not a thing anymore.
- Not sure what happens if a node goes down / a new node is added.
I've considered a custom solution based on mnesia distributed ram-only
tables that would store the pids of the device loops based on their binary
id.The advantages I see:
- Mnesia will take care of distributing, handling down events, etc.
- I need to reinvent the wheel and ensure that when a node goes down,
all the device entries in the distributed mnesia tables related to that
node are removed.
Has someone recently implemented a distributed process registry and can
shed some light for me?
Thank you in advance for your advice ^^_
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions