We are trying to design a globally distributed Azure Cosmos DB and we’re not sure how to best do that:
There is data that should be replicated in every region to improve read performance. This data is updated/added to infrequently, and will be placed in a global database.
However there is data that is added frequently that we don’t want to replicate in all regions, because writing it everywhere would be expensive, and ~90% of the time it will be accessed from the same region. This data will be placed in local databases.
Our main questions relate to this separation of global and local data.
1. How (best) do we reference local data from global data and route requests?
For example, we have Users, and their user data will be stored in the global database. However, Users have Devices (immobile IoT devices, residing in a User’s home) that produce frequent Measurements (sensor readings), and these Devices and their Measurements would be stored in a local database in the region where the devices are located.
If a User requests information for one of their Devices, how do we route the request? How do we know “Oh, their Device is in Canada, go to that database and retrieve the info”? Is an appropriate solution to give the id of a Device a prefix denoting the region it is in? Then we could look in the User document (global) and see the list of Device Ids that belong to the User and know which database the devices are in? This doesn’t seem like an ideal solution.
2. On a related note, if a country requires that each citizen’s data must be stored in a local database within that country, a) how do we route all requests to the local database? b) how does a customer from that country access their data if they are traveling outside that country?
For example, it is possible that all our Germany customer data will have to be stored within the country. That means that German User documents will be stored in Germany, and not globally. If a German comes to Canada and therefore connects to our Canadian app service, how can we 'make it aware' that it should query the German database for the User document?
If you need any additional info or clarifications, please leave a comment!
Thanks in advance!