I'm doing a tutorial and it says "In this guide, we will learn how to build a complete Elixir application, with its own supervision tree, configuration, tests and more".
In plain english, what is a supervision tree in Elixir?
Thanks!
Supervision tree is a tree-like structure of supervised processes, where the structure itself handles starting, terminating, and restarting processes according to our instructions (see restart strategies).
1.1 Supervision Trees Supervisors are processes that monitor the behaviour of workers. A supervisor can restart a worker if something goes wrong. The supervision tree is a hierarchical arrangement of code into supervisors and workers, which makes it possible to design and program fault-tolerant software.
Supervisors are one of the most useful part of OTP you'll get to use. We've seen basic supervisors back in Errors and Processes and in Designing a Concurrent Application. We've seen them as a way to keep our software going in case of errors by just restarting the faulty processes.
What are Elixir and OTP? Elixir is a functional programming language built on the Erlang VM. OTP is a process oriented programming framework integral to Erlang and Elixir.
In Erlang and Elixir applications, structure is imposed by having a top-level "supervisor" processes which starts the other processes in your application. Those other processes can include other supervisors, which also have their own children, and this recursive structure takes the shape of a tree, hence "supervision tree". Supervision of processes is what gives Erlang/Elixir it's fault tolerance features, as failure is isolated to some branch of the tree, where the supervisor of that branch can either restart the failed children, or allow itself to fail as well, bubbling the failure up to the next highest supervisor in the tree.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With