Recovering State After a Crash

This is where we really fulfill the promise of fault tolerance. It’s one thing to restart a process if it crashes and then move on. It’s another thing entirely to restart it and restore the last known good state.

The way we’ll do this is to save a copy of the data outside of the current process, or any other process the current one is linked to. We’ll do this when we initialize the process, and then again whenever the state changes.

Whenever we start a new process, or restart a crashed process, we’ll check for that saved state. If it exists, that means we’re restarting, so we’ll use the saved version. If it doesn’t exist, that means it’s a new process, so we’ll use fresh state.

The storage engine we’ll use is ...

Get Functional Web Development with Elixir, OTP, and Phoenix now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.