Elixir Global PID lookup

In Elixir and Erlang, what are the best ways to manage pid lookups in a cluster?

My current solution:
Inside each node, I use gproc to register my pids with custom keys {:n, :l, “game-1001”}.
Across the entire cluster (tiny cluster less than 5 ec2 instances), I use a global shared
storage like DynamoDb to store the mapping from custom keys to pids.
To find a particular process running a game, I would first check locally and then with DynamoDb.
To maintain the consistency, I monitor each process, remove it from DynamoDb when it dies.
Whenever a died process is restarted by Supervisor, the pid is added to DynamoDb.
This way requests can always be routed to the right node in the cluster.

I wonder if anyone has run into similar problems and may have better solutions.

Thanks

An initial reaction I have is to your:

To find a particular process running a game, I would first check locally and then with DynamoDb.

You are not storing PID’s in a database are you? That sounds very easy to break as PID’s are supposed to be entirely opaque. :slight_smile:

I would personally have an Erlang/Elixir based shared storage, and for this purpose this is a prime usage of mnesia (which can safely store PID’s), however gproc has a genleader setup so it can act distributed as well. Is there any reason that gproc’s distributed mode would not work for you as it would probably be hard to be better for this purpose than that. :slight_smile: