Supervisors Are the Heart of Reliability

Understand reliability in Elixir through supervisors.

We'll cover the following


Think about our previous example; it was both trivial and profound. It was trivial because there are many ways of achieving some kind of fault tolerance with a library that returns successive numbers. But it was profound because it’s a concrete representation of the idea of building rings of confidence in our code. The outer ring, where our code interacts with the world, should be as reliable as we can make it. But within that ring, there are other nested rings. And in those rings, things can be less than perfect.

The trick is to ensure that the code in each ring knows how to deal with failures of the code in the next ring down. And that’s where supervisors come into play. In this chapter, we’ve seen only a small fraction of supervisors’ capabilities. They have different strategies for dealing with the termination of a child process, different ways of terminating children processes, and different ways of restarting them. There’s plenty of information online about using OTP supervisors.

Get hands-on with 1200+ tech skills courses.