0

I'm working on setting up auto failover on the whole stack of my website, which includes mongodb. For the time being, I utilize heartbeat to detect failure of the primary mongos and then change the host name on client side to point to the secondary mongos, which means secondary takes over and become primary. The client always talks to the primary.By the way, I do not use virtual ip because the two mongos locate in different sites.

But as heartbeat only moniters the system's availability, not the application's, I believe this may not be quite reliable. mongos may die with the system still being up. I wonder if there is some kind of mechanism that enables "heartbeat" between mongos processes.

dennis.s
  • 73
  • 1
  • 1
  • 7
  • 2
    The big question here is why? If you just specify all instances in your connection string the driver will do this for you. You don't need to code this yourself. – Neil Lunn Oct 17 '14 at 09:08
  • 2
    And even if that wasn't the case, that'd be relatively easy to do with HA-Linux. Set up DNS for the HA IP. When node1 fails, take over that IP address on node2, fire up mongos bound to at least that IP, done. And of course you can monitor services. But as @NeilLunn correctly pointed out: it simply makes no sense for MongoDB. – Markus W Mahlberg Oct 17 '14 at 11:31
  • Thanks @Neil and Markus, you're right, the driver works and I also considered it. It's just that on the web server side it's calling the php mongo driver directly. If I put two hosts into the connection string, I believe this will introduce extra latency as it need to determine which one is avaliable. plz correct me if I'm naive. – dennis.s Oct 21 '14 at 09:56
  • 1
    @dennis.s You're naive. Blunt, but to the point. The driver connects to the first available. So if you can write code to somehow magically guess which one is available on the first try without testing then you are perfectly welcome to submit that code and we'll all happily use it. Happy coding. – Neil Lunn Oct 21 '14 at 11:08

0 Answers0