Top 3 Erlang Supervisor Restart Strategies

Supervision trees employ strategies like `one_for_one` (restarts only the failed child), `one_for_all` (restarts all children), and `rest_for_one` (restarts the failed child and those started after it) to manage process failures.

The top 3

  1. One-for-One: Independent Process Recovery Champion: The default Erlang supervisor strategy, 'one_for_one,' restarts only the specific child process that terminates, leaving other supervised processes unaffected. This is ideal for applications where child processes operate independently and a failure in one does not compromise the state or functionality of others.
  2. One-for-All: Coordinated System-Wide Reset: When a child process fails under the 'one_for_all' strategy, the supervisor terminates all its other children before restarting every child, including the original failed one. This ensures a consistent state across tightly coupled processes, preventing desynchronization if one component's failure impacts others.
  3. Rest-for-One: Cascading Failure Recovery: If a child process fails, it and all subsequent processes (started after the failed one) are restarted, useful for processes with sequential dependencies.

Sources

Open the full topic