Supervisor Trees: BEAM's Self-Healing Hierarchy

The 'Let It Crash' philosophy is practically implemented through Supervisor Trees, where supervisor processes monitor worker processes. If a worker crashes, its supervisor detects the failure and automatically restarts it in a clean, known-good state, preventing the error from propagating and ensuring system stability through hierarchical fault containment.

The top 3

  1. Top 3 Restart Strategies for Supervisor Trees: BEAM's supervisor trees employ three primary restart strategies: `one_for_one` (restarts only the failed child), `one_for_all` (restarts all children if one fails, ideal for interdependent processes), and `rest_for_one` (restarts the failed child and those started after it, useful for linear dependencies).
  2. Erlang's 'Let It Crash': A Fault-Tolerance Paradigm Shift: The 'let it crash' philosophy, central to Erlang and BEAM, redefines error handling by allowing processes to fail and be restarted in a clean state by supervisors, rather than attempting complex in-process error recovery. This approach, pioneered by Ericsson in the 1980s for telecom systems, enables extreme fault tolerance and high uptime.
  3. Real-World Resilience: Erlang's Uptime Champions: Systems built with Erlang's supervisor trees, like Ericsson telecom switches and WhatsApp, are renowned for achieving exceptional uptime and fault tolerance. WhatsApp, for example, handled billions of messages with a small team, achieving high availability by isolating failures to individual processes and restarting them in milliseconds.

Sources

Open the full topic