Common Use Cases

Get introduced to some use cases where Cosmos DB is a great fit.

Introduction

Before diving into the more technical aspects of Cosmos DB, it’s good to understand which scenarios it performs better in. There’s nothing worse than solving a problem with the wrong tool.

In general, it’s a great fit when we work with a vast amount of data, especially if it’s not relational. The database has no upper limit for scaling if we use it correctly.

Given below are a couple of examples; we need to keep in mind that containers are similar to tables.

Internet of Things (IoT)

Cosmos DB is perfect when building an IoT cloud service.

Imagine we need to build a cloud service to help farmers monitor the temperature of their greenhouse. Our service receives reading from tens of thousands of temperature sensors in multiple countries. We need to contact the farmers when the average temperature of a greenhouse is above a specific threshold for one hour. We need a database that can handle the number of requests and let us process data in real time. Cosmos DB can give us all of that.

Messaging

Chat apps can be another example where our database shines. We must build a messaging app and plan to scale globally.

Similar to the IoT example, we need to handle a massive number of requests, and for each new message, we process it to send notifications or update user interfaces (UIs). On top of that, it must be quick and independent of the user’s location.

Online shops

This example is a bit more tricky because data in a shop is likely related to each other.

However, with the correct planning, it’s possible to set up Cosmos DB to receive tons of orders, payments, shipping information, and more.

Event-driven applications

In general, any application that relies on events is a good candidate.

These are applications built on an event-driven architecture. Simply put, multiple system parts subscribe to specific events and react when they receive one. This pattern is popular with microservices, since event producers and consumers are loosely coupled and scalable independently.

The truth is that Cosmos DB is just a database. The domain doesn’t matter.

  • Gaming

  • Social networks

  • Advertising

  • Pharmaceutical

All of the above are good use cases as long as we need scaling capabilities and storage, and we build it correctly.

By the end of the course, we’ll know the strengths and weaknesses of Cosmos DB, and we’ll be able to decide for ourselves where it’s a great fit and where it’s not.

Hybrid approach

One thing we want to add that is not instantly obvious is that we can use multiple databases in our solutions. We can have highly coupled, cold data in a classic SQL database and hot data in Cosmos DB. If we need fast data access and data writing is not a priority, we can store all of the data in an SQL database and use Cosmos DB as a cache to serve data to specific views per client needs.