Thursday, 10 January 2019

NoSQL Document Database options on Azure - CosmosDB

Overview: Azure has a plethora of options for using NoSQL, I have used RavenDB and DocumentDB a couple of years back. Both are easy and great tools for the right situation, DocumentDB now falls under CosmosDB as a product at Microsoft. However, I feel that CosmosDB would be anyone's default choice today on Azure as DocumentDB is really a feature subset of CosmosDB.CosmosDB: "Azure Cosmos DB is a global distributed, multi-model database (db) that is used in a wide range of applications and use cases. It is a good choice for any serverless application that needs low order-of-millisecond response times, and needs to scale rapidly and globally." CosmosDB is used by Microsoft's Skype, MSN, Xbox, Office 365, Azure products.Def: CosmosDB is a Planet scalable NoSQL JSON database that has multiple API support (including SQL(Core)). Multiple copies/instance around the world (think SQL AOAG).

Encrypted on Azure at Rest and in Motion.

Multiple API's supported including SQL API (DocumentDB) and multiple other JavaScript and Table.

Partitions are managed transparently and users are routed based on geographic location and usage.

One write db and multiple reads. Can set automatic failover so if the write db is unavailable, one of the read db's becomes the write db.

Concerns:

Determinant geo-replication - Use to be 1 master and multiple read copies of the data. Not all copies can be written to but if you have country data residency rules you can't configure data to be within specific regions. I.e. I can't specify certain bits of data are only stored in a specific region. You can specify a region/location for a container, but not split a container. : Check! Not a fact.

Backup and Recovery - Point in time recovery and MS ticket needs to be raised. Can't structure complex backup plans. Take it or leave it approach.

Limited LINQ support

SQL API is very limited compared to SQL relational databases, offering no joins or aggregation capability such as GROUP BY.

Temporal Tables don't exist, there are good auditing options such as the "Change Feed" where all changes can be streamed into an external database/system.

Entity Framework support is limited. Consider a PoC before using.

Consistency (copy data to other read-only debs) 5 options: "Strong" (commit to all dbs and acknowledge state, so slow to align but all reading same data but it may be stale. "Eventual", reads what is in the local db you are going to. The default is "Session". As always, it depends on the requirement.