Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

How to Choose a Supervision Strategy in Elixir: One-for-One, One-for-All, or Rest-for-One

Learn how Elixir’s three supervision strategies differ, when each restart scope fits, and how child restart policies and ordering affect recovery.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. List the supervised processes. For each child, note what state, service, or initialization it requires from the others.
  2. Identify independent recovery. If a child can restart without invalidating its siblings, :one_for_one is usually the narrowest fit.
  3. Record dependency direction. When later-started children rely on earlier children, consider :rest_for_one and list them in dependency order. A failure then resets the failed child and its downstream dependents.
  4. Identify recovery units. Choose :one_for_all when the group must restart together to avoid mismatched or invalid shared state.
  5. 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.

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:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Restart intensity: Elixir v1.20.2 documents :max_restarts with a default of 3 and :max_seconds with 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_significant for :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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.