MongoDB Replica Set Deployment Across Two Data Centers

Hello,
I am currently exploring optimal deployment strategies for a MongoDB Replica Set across two data centers. My goal is to ensure high availability and seamless failover, specifically achieving the following:

  1. In the event of a failure in the primary data center, the secondary data center should be able to elect a primary node and maintain read/write availability.
  2. Once the primary data center is restored, we want the primary node to migrate back to the primary data center.
    My proposed deployment strategy is as follows:
  • Deploy two nodes, including the primary node with the highest priority, in the primary data center.
  • Deploy three secondary nodes in the secondary data center.
    Would this configuration be effective in achieving our goals? Are there any potential issues or best practices we should be aware of?
    Thank you in advance for your insights and recommendations.

Hi @464519755 and welcome to the community forum.

I would recommend you going through the documentation on Replica Sets Distributed Across Two or More Data Centers to understand the best practices needed to deploy.

Let us know if you have further questions.

Regards
Aasawari

Thank you for your response and the provided documentation link.

However, based on the recommendations in the official documentation, I noticed that the suggested replica set configurations across two data centers might encounter situations where write operations are not possible. My goal is to ensure read/write availability at all times, even if one data center fails.

Specifically, I want the secondary data center to be able to elect a primary node and maintain read/write availability in the event of a failure in the primary data center. Additionally, once the primary data center is restored, I want the primary node to migrate back to the primary data center.

My proposed configuration is as follows:

  1. Deploy two nodes, including the primary node with the highest priority, in the primary data center.
  2. Deploy three secondary nodes in the secondary data center.

Would this configuration effectively achieve my goals? Or are there any other recommended configurations to achieve this? I look forward to your further guidance.

Thank you!