The Supervision Tree
A supervision tree is a tree of processes. The upper processes (supervisors) in the tree monitor the lower processes (workers) in the tree and restart the lower processes if they fail. There are two types of supervision tree. You can see them in the following figure:
- One-for-one supervision trees
-
In one-for-one supervision, if a worker fails, it is restarted by the supervisor.
- One-for-all supervision trees
-
In one-for-all supervision, if any worker dies, then all the worker processes are killed (by calling the
terminate/2
function in the appropriate callback module). Then all the worker processes are restarted.
Supervisors ...
Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.