liveBook · Manning

One_for_one strategy

As explained in Elixir in Action, Third Edition

A one-for-one supervisor is a supervisor that restarts a failed child independently without restarting its sibling children.

A one-for-one supervisor replaces only the child process that terminates. Sibling children continue running, limiting a failure’s impact to one supervised worker. section 8.3.2 section 9.1.1

Configure the strategy with Supervisor.start_link/2. The supervisor starts children in specification order, waits for each to finish starting, and then monitors the next. A replacement is a new process with a different PID and no shared state. section 8.3.2 section 9.1.1

Separating a database and cache

A system supervisor can start Todo.Database and Todo.Cache with strategy: :one_for_one. Killing the database server restarts database-related processes without restarting the cache; killing the cache similarly leaves the database running. section 9.1.1

How Elixir in Action, Third Edition covers it

How deep it goes
Explains configuration, replacement semantics, failure isolation, and synchronous startup, while deferring alternative strategies.
Examples
Demonstrates isolated database and cache restarts using Todo.System, Process.exit/2, and Process.whereis/1.
What it assumes
Assumes familiarity with Elixir processes and child specifications, while defining supervision and process replacement behavior.
What you can do after
Operate/configure an Elixir supervisor that restarts failed children independently and verify replacement behavior through process termination.
How it connects
Connects supervisors with child processes, process isolation, GenServer initialization, and fault-tolerant system structure.

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.