can we select my data base in multi-region ( Indian and America )
and have separate shards for each region ?
Take a look at the Segmenting Data by Location tutorial as that sounds like it’s what you’re looking for.
Thanks for the response,
I followed it, but I see two shards are getting created in same Region, not in diffrent countries
Assuming you are planning an on-premises deployment, you can choose whatever granularity of locality and shard zones fits your use case. If you are using MongoDB Atlas, it has a more streamlined Global Cluster feature for M30 or greater sharded clusters.
In sharded clusters, you can create zones of sharded data based on the shard key. You can associate each zone with one or more shards in the cluster. A shard can associate with any number of zones. In a balanced cluster, MongoDB migrates chunks covered by a zone only to those shards associated with the zone.
The example @Doug_Duncan referenced is using zone sharding to segment data by country with deployments in two zones (NA and EU). Segmenting by location is a common use case for zone sharding, but there are other examples like Tiered Hardware for Varying SLA or SLO and Segmenting Data by Application or Customer:
Borrowing the diagram from Segmenting Data by Location:
The N represents however many shards you would like to have.
So that could be:
- Shard 1 (US)
- Shard 2 (Canada)
- Shard N (India)
Or another combination like:
- Shards 1-2 (US)
- Shards 4-6 (India)
You can also use a more granular shard key (for example,
state instead of
country) to create zones like “North India” or “Maharashtra” if those are more suitable for your location-based use case.