Forum Discussion

Mike Jansen's avatar
Mike Jansen
Iron Contributor
Jan 02, 2018

Redesign web application > Move from SQL-server to CosmosDB (or not)

I try to find as much information as possible about CosmosDB but have not found my answer yet. We have a (kind of) straight forward web application (Classic ASP, Javascript, MS SQL server). We have...
  • Joshua Carlisle's avatar
    Jan 02, 2018

    So this is a pretty broad question and tough to answer. The frustrating and truthful answer is "it depends" but to be clear though you can be successful with both.  

     

    I have several CosmosDB implementations behind me and I'm a big proponent but in my experience to be successful it does take a mental shift from the traditional relational normalized data models that has been ingrained into the industry (and our heads) for the last 30 years.  I still work regularly with traditional relational databases but there are several aspects of CosmosDB that continually lead me to frequently recommend it.

    • Serverless - I'm not maintaining a server, worrying about CPU and memory, worrying about storage, worrying about disk IO, worrying about redundancy, etc.  Huge overall reduction in devops efforts and costs.  Allows me to concentrate more on app and not the infrastructure.

    • Development Model - I find I'm more efficient working with a simple JSON Data Model and the CosmosDB (DocumentDB) API over the equivalent traditional database development whether that be Entity Framework or more legacy stored procedure heavy solutions.  Mind you still have to plan\design your data model well (partition keys, etc).
    • Costs -  In our experience so far we've felt pretty strongly that we've had significant costs saving over traditional Azure SQL instances that would provide us the equivalent performance and redundancy (not even counting more abstract operational and devops costs). 

    Saying that I've had some frustrations and challenges - standing out in my mind:

    • Aggregates - CosmosDB has limited support for aggregates that is REALLY challenging.  They say they do but they don't support common aggregates such as distinct and group by (yet). If you need to have aggregates this could be a headache for you.
    • Case Sensitive - Queries are all case sensitive requiring extra work or having canonicalized versions of common search fields (e.g. lower case, etc)
    • Lookup Values - Establishing a pattern I liked for things like lookup values (think dropdowns) and managing those values.

    You also have extra considerations with migrating legacy data. If you are thinking of a "life and shift" to the cloud or if you have a lot of business logic in your stored procedures then you may have a lot of work ahead of you and it may be worthwhile to stay with SQL Server.  You'll also have to think about migrating your existing data. Some application are just naturally more relational and belong in SQL.

     

    I really suggest you pull down some sample projects off of github and get a feel for the development experience. THere is a local emulator so you can do it for free.  Experiment a little on the impact on your data model and how you query and use your data. If you have a "close" data model you can plug it into a cost calculator and get some general costs - running some sample queries will also give you some RU costs for those queries which might help you refine those estimates even further. 

     

    Hope this helps a little. Good luck!

     

     





Resources