mongodbamazon-web-servicesreplicateaws-regions

Set up Mongo Cluster across 2 data centers with writing enabled on both


We're planning to expand our software to the South East Asia region. Our self-hosted Mongo Cluster is fully set up at China's AWS Data Center. How can we set up the MongoDB replicate set to AWS Singapore and allow writing on both regions and rely on MongoDB for asynchronously sync up data behind the scenes?


Solution

  • What you are trying to do is not possible with MongoDB replica set. If you checkout the documentation here:

    A replica set contains several data bearing nodes and optionally one arbiter node. Of the data bearing nodes, one and only one member is deemed the primary node, while the other nodes are deemed secondary nodes

    If you really want to be able to do write operations on more than one server, you will need to shard your collections. You can go through the documentation here to get started.