shortlyportly
Designing for Failure
Hello.
I’m currently reading the beta version of Functional Web Development with OTP and Phoenix and I love the way that the book uses OTP to store state (using Agents and GenServer). I’m thinking about how I could use this technique in my next project but also thinking about failure and recovery (which isn’t in the book yet as it hasn’t been written
)
As an example of the approach I’m thinking of - assume I have an Order which I’d like to model using a process BUT also when details of the order change I’d also want to persist to the database. If one of the attributes I persist to the database is the PID of the process that models the order then IF that process crashes the Supervisor for that process can simply read the last state from the database and recreate the process.
Does this make sense or am I overcomplicating my design. I appreciate that you shouldn’t over-use processes and that the standard way would be to simply use the database for everything but I’m intrigued by the use of process to model state.
I’d love to hear people’s views on the above approach.
many thanks (and have a great day).
Dave
Most Liked
OvermindDL1
Only if there is no heir process. You can tell ets that when its parent table dies then pass it to its heir process, which gets a message alerting them (so that they can re-create its sibling and give it ets back to repeat the process again for example).








