liveBook · Manning

Supervision tree

As explained in Elixir in Action, Third Edition

A supervision tree is a hierarchical arrangement of supervised processes in which supervisors monitor and restart child processes.

A supervision tree is a hierarchy of supervisors and workers that organizes service lifecycles, restarts failed processes, and confines errors to the smallest practical part of a system. section 9.0 section 9.1.6

Figure 9.4 Supervision tree
CH09_F04_Juric3

Use the tree diagram to trace supervisors, workers, service boundaries, startup order, shutdown order, and failure propagation. section 9.1.6

A well-granulated tree provides several operational capabilities:

  • Place each worker under a supervisor so an individual crash can trigger an individual restart while unrelated services continue operating. section 9.0
  • Define startup and shutdown order through parent-child relationships; terminate a supervisor to take down an entire subsystem and its descendants. section 9.1.6
  • Escalate persistent failures: a database supervisor can stop its workers after excessive restarts, allowing the system supervisor to start a fresh database pool. section 9.1.6

A resilient to-do system

Separate the process registry, database, and cache into supervised services. A database error should not stop cached data from being served, and a failed database worker should not affect other database operations. section 9.0

Supervision supports “let it crash”: worker code can avoid defensive recovery when a supervisor can restart the process with clean state. Explicit handling remains appropriate for critical processes or errors with a meaningful local response. section 9.3 section 9.4

How Elixir in Action, Third Edition covers it

How deep it goes
Explains hierarchical organization, startup and shutdown order, restart escalation, and clean-state recovery without detailing supervisor implementation internals.
Examples
Uses a to-do system containing registry, database, cache, database workers, and multiple to-do servers.
What it assumes
Assumes familiarity with concurrent processes and supervisors, then extends those ideas into nested service hierarchies.
What you can do after
Design fault-isolated service hierarchies, reason about failure propagation, and choose clean restarts or explicit error handling.
How it connects
Connects supervisors with workers, process registries, databases, caches, OTP, DynamicSupervisor, and the let-it-crash approach.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elixir in Action, Third Edition. The section links point to the parts of the book it draws on.