Supervisor hierarchy question

Eric Merritt cyberlync@REDACTED
Mon Jan 17 20:21:26 CET 2005


On Mon, 17 Jan 2005 12:03:00 +0000, Chandrashekhar Mullaparthi
<chandrashekhar.mullaparthi@REDACTED> wrote:
> Eric,
> 
> Whenever we need to dynamically create child processes which need to be
> supervised we put them under their own supervisor.
> 
>      +----------------------------------------------------------------+
>      |                                                                |
>      |                    Supervisor                                  |
>      +----------------------------------------------------------------+
>          /       |      |       |          |           |         |
>         /        |      |       |          |           |         |
>        /         |      |       |          |           |         |
>      System     CP1   CP2  CP1_C1_Sup  CP1_C2_Sup CP2_C1_Sup CP2_C2_Sup
>                                 |           |           |         |
>                                 |           |           |         |
>                              CP1_C1       CP1_C2     CP2_C1     CP2_C2
> 
> If CP1 and CP2 are also created dyanmically, I would put them under
> their own supervisor. 

 Easy enough to do and sensable.

> The restart strategy, in the top level
> supervisor, for each CPm_Cn_Sup should be transient so that if that
> particular connection misbehaves, the rest of them are unaffected.

  So each connection process should get its own supervisor? Isn't that
kind of a waste of processes (not that there is any dearth of
processes available).



> You should probably maintain an ETS table which has a mapping from
> connection pool name to process id or have a fixed naming convention so
> that you can generate the name - asking the top level supervisor sounds
> a bit of a bodge.

That was my first thought as well. However, how do you handle the case
of a member of your pool dieing. The Pid changes and then your ETS
table is immediatly out of date. Even if you caught the error you
wouldn't know the Pid of the new process the supervisor starts. What I
ended up doding (and I am very willing to modify this) is to make the
connection_pool a gen_server and custom code what is in effect a
supervisor for the children. This 'smells' pretty bad too as the
actual OTP Supervisor is probably much better coded and better tested.

> cheers
> Chandru
>



More information about the erlang-questions mailing list