russ
russ

Reputation: 61

multi-master in cosmosdb/documentdb

How can I set up multiple write regions in cosmosdb so that I do not need to combine query results of two or more different regions in my application layer? From this documentation, it seems like cosmosdb global distribution is global replication with one writer and multiple read secondarys, not true multi-master. https://learn.microsoft.com/en-us/azure/documentdb/documentdb-multi-region-writers

Upvotes: 6

Views: 2817

Answers (3)

Mani Gandham
Mani Gandham

Reputation: 8292

As of May 2018, Cosmos DB now supports multi-master natively using a combination of CRDT data types and automatic conflict resolution.

Multi-master in Azure Cosmos DB provides high levels of availability (99.999%), single-digit millisecond latency to write data and scalability with built-in comprehensive and flexible conflict resolution support.

Multi-master is composed of multiple master regions that equally participate in a write-anywhere model (active-active pattern) and it is used to ensure that data is available at any time where you need it. Updates made to an individual region are asynchronously propagated to all other regions (which in turn are master regions in their own). Azure Cosmos DB regions operating as master regions in a multi-master configuration automatically work to converge the data of all replicas and ensure global consistency and data integrity.

Azure Cosmos DB implements the logic for handling conflicting writes inside the database engine itself. Azure Cosmos DB offers comprehensive and flexible conflict resolution support by offering several conflict resolution models, including Automatic (CRDT- conflict-free replicated data types), Last Write Wins (LWW), and Custom (Stored Procedure) for automatic conflict resolution. The conflict resolution models provide correctness and consistency guarantees and remove the burden from developers to have to think about consistency, availability, performance, replication latency, and complex combinations of events under geo-failovers and cross-region write conflicts.

More details here: https://learn.microsoft.com/en-us/azure/cosmos-db/multi-region-writers


It's currently in preview and might require approval before you can use it:

enter image description here

Upvotes: 3

dotnetnate
dotnetnate

Reputation: 769

The referenced article states how to implement multi-master in Cosmosdb, while explicitly stating that it is not a multi-master database.

There are ways to "simulate" multi-master scenarios by configuring the consistency level (e.g. session) which will allow callers to see their local copy without having it written to the write region. You can find the details of the various levels here: https://learn.microsoft.com/en-us/azure/cosmos-db/consistency-levels.

Aside from that, consider if you truly need multi-master by working with the consistency levels, considering what acceptable latency is, etc. There are few scenarios that can't tolerate latency, particularly when you have adequate tools to provide a user experience that approximates a local write master. There is no such thing as real-time when remote networks are involved ;)

Upvotes: 1

Tom Sun
Tom Sun

Reputation: 24549

According to your supplied link, based on my understanding. Multi-master in cosmosdb/documentdb is implemented by multiple documentdbs separately for write regions and read the documents from the combined query. Currently it seems that it is not supported to set up multiple write regions in cosmosdb so that don't need to combine query results of two or more different regions .

Upvotes: 2

Related Questions