Best practice for having one centralized database across different regions

App is hosted in North America, Europe and Asia. All regions have the same instance of the app, but connected to different MongoDB databases hosted in Atlas in the same region as the app.

Each region’s app is connected to different database because it would take long for database requests if the app is not hosted in the same region as the database itself.

The biggest issue now is if the user is registered in North America’s instance, his user record will be stored in North America’s database. So if the same user tries to login later in the Europe or Asia instance, he would not succeed since these databases do not have that user record.

What is the best practice to have one centralized database that would be fast for all regions globally. Can that be done with Atlas? Is it possible to host replicas set of one cluster in different regions?

All suggestions and recommendations are welcomed. :smile:

Hi @NeNaD,

Atlas M30+ dedicated clusters have a Global Clusters feature which uses Zone Sharding to support location-aware read and write operations, This is similar to the examples described in Segmenting Data by Location, but Atlas has UI/API to support more straightforward configuration.

If you prefer a video overview, this walkthrough from MongoDB World 2018 may be of interest:

There have been many improvements to Atlas in the ~4 years since this video was recorded (including additional provider regions and Multi-Cloud Clusters) so I recommend reviewing current Atlas documentation if you want to catch up on the latest features. However, this MongoDB World session should provide a good introduction to Atlas Global Clusters.

If you have an Atlas replica set deployment, members can be hosted in different regions if your main concern is read latency. However, each replica set has a single primary so you’ll have to choose a primary region for writes that will cater to the majority of your application users.

You will need a sharded cluster (M30+ on Atlas) to support multi-region writes. Each shard is backed by a replica set, so shard primaries can be distributed for global writes with local secondaries from other shards to support reading cross-region data. The zone sharding feature used by Global Clusters allows you to control location-based zone/shard affinity for writing data.