Running on Ubuntu. Program is in C++. I have 2 process running on different hosts , when one is master and one is slave (don’t have any priority between them, just that only one handle request.). Only one process can be a master and handle request. Two process always up and in case they are crash there is a watch dog that restart them.
The hosts are connected by network cable.
My plan is to ask for keep alive from one to other and in case that slave stop getting keep alive from master it need to change its state to master. When master start up again it first wait to get keep alive and in case not get it set role as master. if get it set role as slave.
I will be happy to get your opinion on:
how to prevent from both to be master at the same time? This is my MAJOR concern. When start up and in connectvity failure, how do you prevent 2 master at the same time?
Do you think that it will be better to query for keep alive or to send keep alive? ( for my opinion its better to ask for keep alive than push )
any other good advices and pitfalls will be more than welcome.