I have an OTP application and I'd like to distribute it over several nodes. I'm quite new to Erlang so what I'm going to ask might sound really basic, but I couldn't find anything online.
To start with, say I want to have two nodes running at the same time. One is the primary one and one is the backup. If the primary falls over, the backup takes over. When that happens, the backup becomes the primary and the node that was the primary, once the application is restarted, becomes the backup. The important thing is that the application has a state and it must not be lost.
My idea is that the primary receives the messages from the user and forwards them to the backup, so they both run at the same time. Only the primary responds to the user though. If the primary node falls over, the backup can take over since it should have the same state.
Hopefully the user will not notice anything.
What's the best way to achieve this?
Thank you very much.
Edit Should have clarified that I'd like the system to work in case of a net split, so persisting the data on hard-drive doesn't look like a viable solution.