Globally Sharded DB and users who change locations

We’re adopting a global sharded db cluster. and we will have users across the globe who need access to all data regardless of where the data originates.


  1. How should we handle setting the shard location for users who travel to other regions. Can we just use the regional servers assigned mongo region? Or should it be user specific?
    ex 1a: Let’s say Alice lives in Australia, she creates new data with the location=“AUS”. What will happen when Alice will travel to US? Should we query her data with location=AUS or location=US ?
    ex 1b: What happens if Alice permanently moves to another country?

1a. How do we handle users who live in countries with data sharing laws that prohibit sharing data to other regions. Can those users still access their own data when they leave? (this is probably a legal question more than a technical one?)
ex: Bill lives in country “A” , which does not allow data that originates there to be shared in country “B”. Bill travels to country “B”, how would you set his read location?

Assumptions: (please comment if these are incorrect)

  1. Each region will have its own primary read / write shards, and also a replica read-only shard from all other regions.
  2. All collections will need a compound shard key, “location” and one other field (can the secondary key be the _id???)
  3. Each server will carry the mongo region as an env var, that will be used for all reads and writes??