spawn() vs. supervisor:start_child()
Thu Dec 16 00:12:10 CET 1999
We're building a long-running application where robustness is a
The application can be a server for several clients (external
processes, not coded in Erlang). Each client may be multithreaded,
so each client's network connection uses a split-transaction protocol
so that each request can be executed concurrently.
We therefore need to launch many kinds of processes dynamically:
- one for each new connection
- one for each request on a connection
- occasional dynamic processes related to the execution
of a request, e.g. lock managers
My question is whether we should be looking to put these dynamic
processes in a supervision tree, or is it sufficient to link them
to a process in the supervision tree? Which is the better style?
Is it ever a good idea to dynamically create supervisors?
An examination of the code in Kernel, hopefully an example of good
design in Erlang, reveals a few top-level supervisors, but many
occurrances of spawn()/spawn_link() and few of start_child().
More information about the erlang-questions