Technology / Programming

What is CosmosDB?

What is CosmosDB?
Follow us
Published on January 5, 2023

CosmosDB is a document-driven database hosted by Microsoft’s Azure cloud services. It’s similar to MongoDB. Let’s dig a bit deeper. 

There are many different types of databases, but the two big ones are SQL and NoSQL variants. Postgres and MySQL are popular examples of SQL-driven databases. MongoDB is the go-to NoSQL database option. CosmosDB is essentially a cloud version of Mongo hosted by Azure. 

The difference between SQL and NoSQL databases is how data is stored and organized. SQL databases resemble Excel spreadsheets. Each table in a SQL database contains data for a specific thing like user information. Each column in a SQL table contains specific values like age or email address.  Each row in a SQL table represents different entries. 

A NoSQL database like MongoDB and CosmosDB uses JSON objects, however. Each JSON object is called a document. Documents contain a mishmash of data, and each document entry in CosmosDB may not have the same data or data model. 

For instance, a user record in CosmosDB may look like this:

{
  _id: “kjasfjhq3r09sdfdsflkj34”,
  Name: “John Doe”,
  Age: “34”,
  isVerified: true,
}

Document-driven databases are far easier to implement and manage than SQL-driven databases. They require much less planning for implementation. It’s possible to change how documents are written in CosmosDB as apps age and requirements change. SQL-driven databases require a lot of work restructuring and re-normalizing tables. 

An Overview of CosmosDB

In this video, Knox Hutchinson provides an overview of CosmosDB.

Ready to Learn CosmosDB?

Check out CBT Nuggets trainer Knox Hutchinson’s CosmosDB training. Knox does a deep dive into CosmosDB — teaching you some nifty tricks like how to use SQL commands to pull documents from Cosmos. Sign up for a free 7-day trial to start learning CosmosDB more in-depth today!

What are the Benefits of CosmosDB?

Why do developers love CosmosDB? I’m glad you asked because I was going to explain the benefits of using CosmosDB either way. 

Azure offers a lot of free services. CosmosDB includes a generous free tier. For hobby developers, startups, and small businesses, the free tier for CosmosDB is an excellent option. It offers 1000 R/Us and 25Gbs of storage free. If a business needs to change that down the road, CosmosDB can be scaled easily to a paid tier. 

Speaking of scaling, like all cloud products, CosmosDB can autoscale. This time I mean the database itself can build itself out as it needs more resources. This is an interesting concept for document-driven databases like CosmosDB. 

CosmosDB works differently than SQL. SQL databases are scaled vertically. That means throwing more processing power at them. CosmosDB scales horizontally, however, much like MongoDB. Instead of increasing the CPU power available to the CosmosDB database, another instance is created instead. CosmosDB automatically handles moving between instances as needed. 

That provides another huge benefit. CosmosDB is capable of being replicated regionally. An instance of each CosmosDB database can live in the United States, Australia, the UK, and other Azure data centers. Moving the database instances closer to users increases application response times. 

Likewise, if a CosmosDB instance has issues in one region, your application can pull information from an instance in another region. It’s like having built-in failover services. 

Of course, CosmosDB doesn’t need to autoscale. You are capable of restricting how many resources CosmosDB has access to in Azure. Limiting CosmosDB resources makes budgeting for cloud services easier and more predictable. 

Final Thoughts

Understanding how CosmosDB works is crucial for passing the AZ-305 certification test to become an Azure Solutions Architect Expert. That may not be your interest, however. Many hobby developers and small businesses need a database solution that’s easy to get up and running fast. That’s the exact reason I found MongoDB and CosmosDB. 

Whatever the reason is, before jumping into Azure, take a CosmosDB online course first. CosmosDB is deceptively simple and yet extremely powerful. There are a lot of excellent features built into Azure services. 

For instance, if your company outgrows CosmosDB, it can be migrated to another Azure database solution. Likewise, if you need to learn CosmosDB and are a SQL guru, SQL syntax can be used to reference CosmosDB documents, which is something Mongo doesn’t offer. 


Download

By submitting this form you agree to receive marketing emails from CBT Nuggets and that you have read, understood and are able to consent to our privacy policy.


Don't miss out!Get great content
delivered to your inbox.

By submitting this form you agree to receive marketing emails from CBT Nuggets and that you have read, understood and are able to consent to our privacy policy.

Recommended Articles

Get CBT Nuggets IT training news and resources

I have read and understood the privacy policy and am able to consent to it.

© 2024 CBT Nuggets. All rights reserved.Terms | Privacy Policy | Accessibility | Sitemap | 2850 Crescent Avenue, Eugene, OR 97408 | 541-284-5522