MongoDB.live, free & fully virtual. Register Now MongoDB.live, free & fully virtual. Register Now

Active Active Sharding

Hey All,

I have a requirement to build an active-active environment in MongoDB. Please confirm if this is possible with MongoDB. Primary will be hosted on each data center and will have bi-directional replication.

Hi @Rajavignesh_Paranira,

It’s not officially supported by MongoDB but there are some alternatives and solutions.

Cheers,
Maxime.

1 Like

Thank you Maxime for your input.

Mongo Mirror is supported only for MongoDB Atlas.

For active-active configuration, to go with Partiotined (Sharded) Database and would like to know how the data is being replicated from one data center to another data center within the Sharding.

Sharding != Replication.

Replication is based on the Replica Set architecture. Usually one Primary and 2 Secondaries which replicate the write operations happening on the Primary. See https://docs.mongodb.com/manual/replication/#replication-in-mongodb.

Sharding allows you to split your entire data set and distribute it across multiple Replica Sets (=shards), so each shard is responsible for only 1/N th of the data (N being the number of shards you are running).

The number of primaries and secondaries per shard is at your discretion and of course you usually put the servers keeping the same set of data in different data centers. It doesn’t change the fact that one primary responsible for 1/N th of the data is only in one place at a given time.

See https://docs.mongodb.com/manual/sharding/#sharded-cluster.

Usually you don’t shard before 1 or 2 TB. But there could be other motivations for sharding. MongoDB Atlas is capable of deploying such a complexe infrastructure and configure it automatically.