When is the global distribution decided?
Configuring global distribution in Azure Cosmos DB is a turnkey operation that is performed when an account is created or afterward.
How is the cost evaluated for accounts with replicas in multiple regions?
RU/s * number of regions
For example, consider a solution that uses 1000 RU/s per hour, data is written to one azure region and replicated to five other the cost will be , 1000*6
What settings must be enabled for failover?
By default, automatic failover is not enabled in Azure Cosmos DB. Automatic failover must be enabled before defining a plan. Once enabled, the read regions can then be sorted by order of failover priority. After sorting, the new priority list can then be persisted and applied to the account.
How can we configure the preferred region for request in azure cosmos db?
The .NET SDK for azure cosmos db for no sql includes configuration classes that can be used with CosmosClient class to configure which region you want the SDK to target for requests.
In what ways can the .NET SDK be configured to choose the preferred region?
- Use the ApplicationRegion property to configure a single region for requests
- Use the ApplicationPreferredRegion property to configure a list of preferred regions.
What are the different ways in which a single region for requests can be set via ApplicationRegion?
- The CosmosClientOptions class contains a set of configuration options for new SDK client instances.
- You can use the Microsoft.Azure.Cosmos.Regions static class which includes built in string properties for various azure regions.
- Use a CosmosClientBuilder fluent classes to construct a new client with the application region set.
You’ve created a brand new Azure Cosmos DB account with a write region in West US and two read regions in UK South and Japan East. You have made no further configuration changes from the default configuration for a new account. There’s a current data center outage in West US. What will Azure Cosmos DB do as a failover action?
Nothing will happen. You need to enable automatic failover before a failover can occur.
Which property of the CosmosClientOptions class in the .NET SDK for Azure Cosmos DB for NoSQL is used to configure a list of preferred geo-replication regions?
ApplicationsPreferredRegions
What is the order of consistency levels in azure cosmos db?
Strong
Bounded Staleness
Session
Consistent Prefix
Eventual
first one is the strongest consistency, to weaker consistency at last.
Which consistency guarantees that read operations will return the most recent version of the item?
Strong
This characteristic causes strong consistency to have the highest latency as it must wait for commits to replicate across large geographical distances.
What is the difference between bounded staleness and strong?
Bounded staleness is similar to strong, except that reads are allowed to lag behind writes upto a defined threshold. The threshold could be defined as –
K version of an item lag behinds the write
T time interval lag behind the writes
What is session consistency?
Session consistency provides read your own write guarantees within a single client session or where the session token is passed between the SDK and the client. Outside of that, consistency guarantee is relaxed to either Consistent Prefix or eventual.
What is consistent prefix?
Consistent prefix allows for looser consistency and higher performance while guaranteeing reads, which lag behind the writes will appear in the order in which they were written.
What is eventual consistency?
Eventual consistency is the weakest form of consistency where reads lag behind writes and reads may appear out of order. However, eventual consistency will have the lowest write latency, highest availability, and potential for most read scalability compared to other options.
What is the default consistency level of cosmos account?
Session
What is used to change the default consistency level?
ItemRequestOptions class contains a ConsistencyLevel property that has to be configured. This is done for a specific request. However, if you wish to change for the entire Cosmos Client, use CosmosClientOptions.
How is session consistency managed?
When session consistency is used, consistency is managed using the session token. This token is then passed back and forth between azure cosmos DB and the client to ensure the client gets read your own writes guarantees.
In the .NET SDK for Azure Cosmos DB for NoSQL, which C# class is used to configure session tokens and consistency levels on a per-request basis?
ItemRequestOptions
Which consistency is not available in multi region writes?
Strong
What are the different conflicts that can occur in case of multi-region conflict?
- Insert – This conflict occurs when more than one item is inserted simultaneously with the same unique identifier in multiple regions.
- Replace – Replace conflicts occur when multiple client applications update the same item concurrently in separate regions.
- Delete – Delete conflicts occur when a client is attempting to update an item that has been deleted in another region at the same time.
What is the default conflict resolution policy?
The default conflict resolution policy in Azure Cosmos DB is Last Write Wins. This policy uses the _ts to determine which item wrote last.
What happens in case of a delete conflict?
In case of delete conflict, the operation to delete an item will always win out over other operations.
Can we change _ts as the default for last write wins policy?
While the _ts property is the default for the last write wins policy, you can configure any numeric property for this policy by configuring a conflict resolution path. You can use the .NET SDK for azure cosmos DB for NoSQL to configure the custom conflict resolution path.
Can a conflict resolution path be created on existing containers?
No. A conflict resolution path can only be created on new containers.
Can a developer write their own cusom conflict resolution path?
Yes
How is a custom conflict resolution path created?
A custom resolution policy will use a stored procedure to resolve conflicts between items in a different region. All custom stored procedures must be implemented using the following java script function signature –
function <function name>(incomingStream, existingItem, isTombstone,conflictingItems)
What is the meaning of the parameter of the function used to create custom conflict resolution policy ?
existingItem – The item has already been committed
incomingItem – The item that is being inserted or updated that generated the conflict.
isTombstone – Boolean indicating if the incoming item was previously deleted
conflicingItems – array of all committed items in the container that conflict with incoming items.
What happens if the custom conflict resolution policy is created without a stored procedure?
In this case, conflicts are written in the change feed. The application code then manually resolves conflicts in the feed.
You are creating an application that will be deployed to various regions across the globe while being backed by a globally distributed Azure Cosmos DB account with multi-region write enabled. For each application region, you would like the .NET client app to select a specific region for read/write operations, and then have the SDK determine fallback regions based on their proximity to your selection. Which method of the CosmosClientBuilder should you use to accomplish this task?
CosmosClientBuilder.WithApplicationRegion
You have a large data solution running on Azure Cosmos DB with multi-region write enabled. Your team would like to write an application to read conflicts from the conflict feed and then resolve them using manual code. What resource[s] should you create for this scenario?
Just a custom conflict resolution policy
Foolishly Yours,
Avantika Tanubhrt
Happy Learning 🙂

Leave a comment