Recommended Free Tools
Choose the strategy by deciding which processes must be restarted together to recover safely: :one_for_one restarts only the failed child, :rest_for_one restarts that child and every later child in the list, and :one_for_all restarts the supervised group. These are restart scopes, not automatic dependency detection; the right choice follows from how your children depend on one another and share state.
Compare the three restart scopes
Elixir’s Supervisor documentation defines these strategies for unsuccessful, restart-eligible child terminations. As the documentation puts it: “In the above, process termination refers to unsuccessful termination, which is determined by the :restart option.” The strategy controls the scope of recovery; the child’s restart policy determines whether a termination qualifies.
As an Amazon Associate I earn from qualifying purchases.
| Strategy | What restarts after an eligible failure | When it fits | Trade-off |
|---|---|---|---|
:one_for_one |
Only the terminated child. | Siblings are independent or remain valid while one child recovers. | If children share state or rely on one another, a single-child restart may leave the group inconsistent. |
:rest_for_one |
The terminated child and children started after it. | Later-started children depend on earlier ones, so a failure invalidates the downstream processes. | List order affects recovery; incorrect ordering can restart too many or too few children. |
:one_for_all |
All the other children are terminated, then every child, including the failed one, is restarted. | The children must be initialized together to restore shared state or a coordinated session. | A localized failure triggers the broadest restart and can interrupt healthy work. |
Choose based on dependencies and consistency
Map the relationships between children before selecting a strategy. The following guidance is an architectural inference from the documented restart behavior; Elixir does not infer dependencies or prescribe one strategy for every application.
- List the supervised processes. For each child, note what state, service, or initialization it requires from the others.
- Identify independent recovery. If a child can restart without invalidating its siblings,
:one_for_oneis usually the narrowest fit. - Record dependency direction. When later-started children rely on earlier children, consider
:rest_for_oneand list them in dependency order. A failure then resets the failed child and its downstream dependents. - Identify recovery units. Choose
:one_for_allwhen the group must restart together to avoid mismatched or invalid shared state. - Validate the scope against failure cases. Ask whether a child failure leaves siblings usable, whether dependent children need fresh initialization, and whether interrupting the whole group is acceptable.
Child order matters for :rest_for_one
A supervisor starts children in the order they are listed and shuts them down in reverse order, as described in the child specification documentation. With :rest_for_one, the children after the failed child form the restart tail. Order children so that this tail corresponds to the processes whose dependencies may have been invalidated, then review that ordering whenever child specifications change.
#1 Best Overall
Check restart eligibility separately
A strategy does not override a child’s :restart setting. The child specification options describe three policies:
:permanent— restart the child whenever it terminates.:temporary— never restart the child.:transient— restart only after abnormal termination.
Consequently, the strategy’s scope applies when a child termination is restart-eligible; it does not mean every exit will trigger a restart.
Keep restart intensity and shutdown behavior in view
The strategy defines which children are affected by a restart. Other supervisor settings govern separate parts of its operation:
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall- Restart intensity: Elixir v1.20.2 documents
:max_restartswith a default of 3 and:max_secondswith a default of 5 seconds. These are documented defaults, not universal recommendations. Review them if repeated failures could exceed the configured restart intensity. See the Supervisor options. - Shutdown: Child specifications include shutdown behavior that affects how children are stopped; it does not alter the basic restart-scope definitions. See child specification options.
- Automatic shutdown: Elixir v1.20.2 lists
:never,:any_significant, and:all_significantfor:auto_shutdown. This setting concerns supervisor shutdown when significant children exit, not the choice among the three restart strategies. Significant-child behavior also depends on child restart settings. See the Supervisor options.
Use current APIs for new supervisors
For new code, use current child specifications and Supervisor APIs rather than legacy helpers. The Elixir v1.19.3 documentation marks Supervisor.Spec helpers such as supervise/2 as deprecated: Supervisor.Spec documentation.
Rank #3
If the supervised population is dynamic, consult DynamicSupervisor. It addresses dynamic child supervision, a separate concern from choosing the static :strategy scope for a supervisor’s children.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




