20192019. 12. 17. 10:44

Azure Cosmos DB에서 multiple write regions 기능을 활성화 하면 지정된 single write region 설정보다 어플리케이션이 위치한 지역에 따라 쓰기 성능을 향상시킬 수 있습니다. 

.NET SDK v2에서 이 기능을 사용하기 위해서는 반드시 UseMultipleWriteLocations true로 설정하고 SetCurrentLocation 함께 사용해야 하는데 만약 A, B, C 3개의 multiple write regions 가 있는 경우 SetCurrentLocation 설정은 어떻게 해야 할까? 

만약 이 값을 policy.SetCurrentLocation("B region"); 라고 명시하여
어플리케이션을 배포하였다면, 어플리케이션은 A, B, C 지역 B 먼저 찾아갑니다. 만 B 지역이 가용하지 않다면, SetCurrentLocation 통해 A, C 가까운 지역을 찾아갑니다. 이에 추후 새로운 multi-master 지역을 추가하더라도 어플리케이션 레벨에서의 변경이 필요하지 않습니다.

Within the ConnectionPolicy, set UseMultipleWriteLocations to true and pass the name of the region where the application is deployed to SetCurrentLocation. This will populate the PreferredLocations property based on the geo-proximity from location passed in. If a new region is later added to the account, the application does not have to be updated or redeployed, it will automatically detect the closer region and will auto-home on to it should a regional event occur.

Configure multi-master in your applications that use Azure Cosmos DB
https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-multi-master


Java Async SDK에서 지원하는 setPreferredLocations 설정의 경우 A, B, C, D 지역 중에서 B, C 지역만 설정하였다면 B 지역을 먼저 사용하고 가용하지 않을 경우 C 지역으로 찾아가게 됩니다.
만약 C 지역도 가용하지 않다면 특별한 사례로 첫 번째 지역인 A 지역으로 찾아가게 되며 리스트에 명시되지 않은 D 지역은 찾지 않게 됩니다. 

Connecting to a preferred region using the SQL API
https://docs.microsoft.com/en-us/azure/cosmos-db/tutorial-global-distribution-sql-api#connecting-to-a-preferred-region-using-the-sql-api


[참고자료]
Azure Cosmos DB Multi Master Deep Dive (Concept + Demo)
https://www.youtube.com/watch?v=uPYmacs2nlw


작성자: Lai Go / 작성일자: 2019.12.17

Posted by Lai Go