MongoDB Failover Time

failovermongodb

I have a MongoDB 2.4 replica set of six nodes and an arbitrator running in a test environment. I was testing the fail-over response time and it was around forty-five seconds.

Keep in mind, reads are set to secondary-preferred, so only writes are disrupted during this time. So it isn't as bad as a complete failure, but it is an issue.

I did some research on bringing that time down and it seems it is set that high to avoid failing over on a lagging connection and to avoid "flapping," which some have described as multiple elections occurring rapidly. Past altering the source code, I really haven't found a way to decrease the failover time.

Any way to get this down to under thirty seconds? The lower the better.

Best Answer

How about giving a secondary a higher priority?

local.system.replset.members[n].priority

set up the master as 5, the secondary you want to fail over as 4, the third as 3, and so on.

That way, there will be fewer issues with elections.