In this edition of the .NET Fiddle Newsletter, we will talk about Microsoft’s NoSql database Cosmos DB and how database throughput is calculated in RUs.
This newsletter is brought to you by “Big Trouble in Little China" (1986).
When I was a kid this was one of my favorite movies. I was going through my “kung fu” phase and I just couldn’t get enough Kung Fu movies. Jackie Chan, Bruce Lee, Jet Li, and 100s of Shaw Brothers films. I saw them all, but “Big trouble in little China” has a special place in my heart.
Watching it again after many years, brought back a lot of emotions. Fear of Lo Pan, amusement from a constant stream of Jack Burton one-liners, and the godlike powers of three storms. This movie had a lot of everything that we call movie magic.
Explore Cosmos
Here is the fiddle that implements Cosmos DB repository and shows the RUs cost of different Cosmos DB actions:
https://dotnetfiddle.net/z9evjF
Cosmos DB is a NoSQL database hosted on Azure. It is different from SQL databases like “SQL Server” in several major ways.
Flexible schema
Cosmo DB is a document database meaning that records are stored as JSON documents and not as rows in tables. This allows to add or stop using record properties without having to modify the database schema.
Scales horizontally
Unlike SQL Server which is scaled vertically, the CosmosDB is scaled horizontally. That means we can just keep adding new servers which add more storage and processing power to DB.
Short latency for geo-distribution
For global applications, it is good to place keep the data close to where your users are. Cosmos DB makes it easy to do so by creating local replicas of your DB where you can read and write data.
Multiple APIs
Cosmos DB supports multiple database APIs including the native Core (SQL) API, API for MongoDB, Cassandra API, Gremlin API, and Table API. So if you have past experience with MongoDB, you can use MongoDB API. I usually just stick to Core(SQL), since it has much better support from MS than other APIs.
Great power comes at great RU cost
Archimedes once said: “Give me a lever long enough and a fulcrum on which to place it, and I shall move the world. “ I know what you are thinking. What the hell is the fulcrum? …
With Cosmos DB the lever is measured in RUs (no, not Rubles, Request Units). You can perform small actions using only 1 or 10 RUs, but for more complicated actions you can go all the way up to 10000 RUs or more. The number of RUs for an operation is based on Item Size, Item Indexing, Item Properties count, and many other factors. Best to just run it in Cosmos DB portal and see how many RUs the operation actually uses.
The RUs pricing calculator is here:
https://cosmos.azure.com/capacitycalculator
Try Cosmos DB for FREE
To see if Cosmos DB can fit the needs of your application, you can try it for free here:
https://azure.microsoft.com/en-us/try/cosmosdb/
Did you know that
The test screening for the movie was so overwhelmingly positive that Russell and Carpenter thought the movie was going to be a huge hit. Unfortunately, 20th Century Fox hardly put any effort into marketing and promoting the movie, so it was a box office bomb. Luckily it went on to be a huge cult hit through home video.
Most recent posts:
.NET Fiddle screams, but no one can hear it in space
Creating interactive voice action for Google Speaker/Assistant.
.NET Fiddle learns Karate: strike first, strike hard, no mercy!
Parse the HTML page into structured and readable data.
If you want to unsubscribe, click on the unsubscribe link at the bottom of this email, just don’t accidentally click on the nearby link to give your soul to Lo Pan.
Big Trouble in Little China is a classic!! It had everything, kung fu, weapons, magic, adventure, and Kim Cattrall!! The little floating eyeball tumor always grossed me out!