0

I am exploring MongoDB replica-sets and I would like to know how to handle fail-over from the application.

Following is my scenario:

Lets assume I have a replica-set with three nodes, say A(Primary), B(Secondary) and C(Secondary).

1.From my application, which host should I connect to? A?

2.What will happen when host A fails? One secondary (say B) will take over as primary. Should my application be designed to handle this transition and connect to B now?

Thanks in advance. I have been confused on how to design the application while maintaining High Availability with replica-sets.

Nataraj
  • 379
  • 7
  • 18

1 Answers1

1

Your application connect string can list all those addresses (or some of them). Mongodb driver knows which one to connect. Basically you just need to connect one of working nodes (even to secondary) and your application get's automatically all those addresses and knows which one to connect. This works also when primary is transferred to other node, your application gets information what is address of new primary.

JJussi
  • 1,540
  • 12
  • 12