[erlang-questions] Logic in the supervisor?
Mihai Balea
mihai@REDACTED
Sat Apr 9 14:14:14 CEST 2011
On Apr 8, 2011, at 8:05 PM, Mike Oxford wrote:
> I have a pool of resources, say 10k children(FSMs) each holding a resource.
>
> If I want to remove a resource from the pool, of which they may be duplicates, I have two options.
>
> 1) Walk the list of children and tell each one "hey, if this is you, close up shop."
> 2) Maintain a dict/ETS of all resources, which has more run-time overhead and a higher likelyhood
> of "something happening."
>
> If the supervisor dies, all resources are shut down as they're children, so having the supervisor maintain
> the dict/ETS is an option.
>
> Having another FSM outside the call-tree maintaining that status is an option but, in the case of that
> FSM going down then all resources are "lost" and should be released....which minics the case of
> a supervisor going down..
>
> So...
> Do I maintain state external to the supervisor or..
> Have the supervisor maintain state or...
> Just deal with the message-storm on resource removal?
Have you looked at proc / gproc?
If your children can be identified by some sort of name or tag, then it might be a good fit for you.
Mihai
More information about the erlang-questions
mailing list