Process communication in a dynamic supervision setup

When you start GenServer with {:global, term()} you can only have one instance per cluster for a specific term(). Starting with {atom(), node()} would have one per node. Different runtime characteristics for different use case.

With {:global, term()} you could use GenServer:call/cast( {:global, term()}, request ) instead of doing a whereis/1 each time. GenServer would route the request to the correct node for you.

We are not in the scope of a distributed system right now. Everything is still local.

Have you actually checked? It’s not an exceptional case for processes to go down, something like

If you are assigning labels dynamically (after init), then you can use Process.monitor/1 to receive DOWN messages, then restart or handle appropriately.

Eg. I have one design where processes are supervised but they are transient and I monitor/restart them under another GenServer.

Could a combination of pg2 and assigning unique names to the processes solve your problem ?