I have been coding changes to a product so it will work with Cosmos DB as a “drop in” replacement for MongoDB via the MongoAPI. Several thousand lines of “just for CosmosDB” later I would say that “drop in” is not exactly the right words. Not only is CosmosDB have a few bugs, dozens of incompatibilities but most if it is poorly documented, undocumented, or the worst. Features are documented but done with “alternative facts” so you think they should work BUT THEY DON’T.
Let me start by saying: Cosmos is not Mongo. It is the square-peg-in-round-hole situation writ large. The differences may only be a few things but like the sex of humans, those small differences can be key. There are just some things Cosmos just won’t do the same way as Mongo.
Speed – Cosmos defaults to about 100 writes per second. A local Mongo instance will do 10,000/sec. Not a truly fair comparison but just realize that a decent Cosmos instance will cost about the same as a decent car every year. They were touting great things like “You can have a million transactions a second if you want”. Of course they don’t mention it but it would cost you around 350 million dollars a year for that privilege. If you need this I suggest you build a couple of your own datacenters instead. I bet it would be cheaper for the same performance and you’d own a couple datacenters when you were done!
Indexing – Mongo indexes what you want and is slow if you search on non-indexed fields. Cosmos indexes everything so performance will cost you more money and if you search on a non-indexed field it will throw an Exception saying you shouldn’t do that. Yay!!!
Consistency or the Lack Thereof. In Mongo if you read a record after you write it you get the stuff you wrote. In Cosmos, using the Mongo API, you don’t. Well, sometimes you do and sometimes you don’t. The documentation says it has Session Consistency by default. One would expect all of your access from the same variable in the same process would be in the same Session. You would be wrong. None of your reads and writes are in the same session and there is no way to specify a session. Double Yay!!!