[erlang-questions] simple_one_for_one supervisor - what happens at restart? (also: gen_tcp)
Ryan Stewart
zzantozz@REDACTED
Sat May 14 18:57:23 CEST 2016
On Sat, May 14, 2016 at 3:28 AM Loïc Hoguin <essen@REDACTED> wrote:
> The primary function of supervisors is to provide a hierarchy of
> processes belonging to an application. With such a hierarchy it becomes
> possible to find and query information about any single process in your
> system in a standard manner.
>
> I'm rather interested in this aspect of supervised processes. Especially
in the case of a simple_one_for_one supervisor, it's unlikely that the
supervised processes will be registered, and it's possible that there could
be a rather large number of them--maybe in the tens or hundreds of
thousands, depending on the use case. I'm curious how others deal with
finding a specific temporary process if, for instance, you want to check on
the progress of the work it's doing.
My current solution is to have a locally registered "manager" process as a
supervised sibling to the SOFO worker supervisor, and the manager just has
a dict that maps UUIDs to worker PIDs. I.e. creating a "worker" process
entails both a supervisor:start_child() call and storing the worker id ->
pid mapping in the manager. Is this a typical way to handle temporary
workers?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160514/83250de1/attachment.htm>
More information about the erlang-questions
mailing list