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

OTP is the set of behaviours and conventions that helps an Elixir application coordinate concurrent processes and recover when they fail. The practical progression is to use a GenServer for a process that handles requests, a supervisor to manage related processes, and an OTP application to start the top-level supervision tree as part of the runtime.

What OTP means in an Elixir application

OTP is not a single library or a replacement for Elixir. It is a framework of behaviours and conventions for structuring concurrent systems and managing their lifecycles. A GenServer is a common way to implement a process that handles messages and requests; a supervisor starts and monitors child processes; and an OTP application is a runtime unit that can be started or stopped as a whole.

Mix projects and OTP applications are related, but they are not the same thing. Mix manages development work such as compiling and testing a project. The runtime starts the OTP application and its configured dependencies. An application callback can return a supervisor as its starting process, putting the supervision tree at the top of the application’s process structure. Elixir’s guide to supervisors and applications walks through this arrangement.

How GenServer calls and casts differ

Use GenServer.call/3 when the caller needs a reply: it waits for the server to respond. Use GenServer.cast/2 when sending a message without requiring a response; the cast returns without confirming that the server handled the work. That asynchronous contract is not inherently unsafe, but the immediate return from a cast is not evidence that the operation completed. A later successful call can establish that the server is available and has processed earlier work, as described in Elixir’s GenServer guide.

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

What a supervisor does when a child fails

A supervisor starts, stops, and monitors child processes according to their child specifications. It starts children in the order specified and terminates them in reverse order. When a child terminates, the supervisor applies the configured restart strategy, which determines how broadly the failure affects its siblings.

Choose a restart strategy based on sibling relationships

Strategy Failure scope When it fits
:one_for_one Restarts only the child that terminated. Use when sibling processes can recover independently.
:one_for_all Terminates and restarts all children. Use when siblings form a tightly coupled unit that must restart together.
:rest_for_one Terminates and restarts the failed child and children started after it. Use when later children depend on earlier children in start order.

These descriptions follow the Erlang/OTP Design Principles guide. The right choice depends on actual process dependencies: a start-order relationship matters for :rest_for_one only when later siblings rely on earlier ones.

Restart intensity limits repeated failure

A supervisor also has a restart-intensity limit: a maximum number of restarts within a configured time window. If that limit is exceeded, the supervisor terminates its children and itself. A higher-level supervisor can then take responsibility for recovery. This prevents a child that repeatedly fails for the same reason from triggering an endless restart loop.

Check compatibility for your Elixir and Erlang/OTP versions

At the time of the current Elixir documentation snapshot, the official site labels Elixir v1.20.4 stable and lists Erlang/OTP 27, 28, and 29 as supported. Compatibility changes over time, so check the official documentation for the Elixir version you install. The site provides versioned documentation; when working in an older project, consult the documentation for that release rather than assuming every latest-version API or recommendation applies unchanged.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Where to continue learning

The official Elixir Learning page collects books, courses, videos, and other learning resources. For a book-length treatment, the publisher’s contents for Elixir in Action, Third Edition include GenServer, fault tolerance and supervisors, supervision trees, dynamic supervision, OTP applications, releases, and distributed systems.

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.