How to set up a multi-master MongoDB in stages?


We are building a web solution that will be used globally. To support the eventual target audience we are trying to design the solution so that it’s hosted in 3 different data centers. users will be routed to the closest server based on location data.

Having said that, to start, we will only deploy this solution to one datacenter, and only users from North America will have this solution available to them.

Technology Set

MongoDB and RethinkDB have has been short listed for the database. We need something that allows multi-master replication, since we need to be able to read and write to the database from any one of the data centers.


Management wants something delivered in two weeks. The same usual story. They over committed us… under staffed etc.

I need to come up with a design that’s future proof. I’m not familiar enough with MongoDB yet to be confident that I’ve identified all the pieces that I need to deliver right now, and still be future proof.

What I think I know So Far

I think in MongoDB terminology, each data center is a zone. In the final solution, I will have one zone per data center, and in each zone, I will have a primary shard. So in the North America zone, I will have shard A… and that is it’s primary shard. Shard A will be replicated to the Asia Zone… so that if the north american data center goes down, Asia will have it’s data and can kick in.

I also understand that I need to be careful with the shard keys because once I create them, I can’t change them. So I’m thinking of somehow creating a shard based on location. I will know that a request is coming from japan, I send it the “asia” dc, but if it’s coming from France, it’s gonna hit the European DC.

Specific Questions

I’m reading this article; Do I need a mongos router in each data center? What about the config server? If I start with just creating “shard A” in Zone North Am, what priority do i give it? Can I worry about priority later?

I’m still mulling things over so I’m sure there are questions I should be asking that I haven’t even thought of yet. If you have any comments or suggestions, I’m all ears. Thank you