Applications developed in today’s time need to be highly responsive and highly available. They must adapt to enormous changes in real-time at peak business hours, store ever-increasing volumes of data, and make that stored data available for users a fraction of seconds. Achieving such low latency and high availability seems to be possible only when you deploy these applications’ Instances in data centers.  Building a similar globally distributed database that you would need to host on your own data centers, using your connections and other resources is surely tiresome and requires a huge effort.

However, with cloud computing and platform-as-a-service it has become quite easier. The most popular service, Azure Cosmos DB addresses the above challenges and takes it to the next level. It is a completely managed service that takes care of database administration for you, including automatic management, upgrades, and patching. This blog will help you dive deep into the world of Azure Cosmos DB and broaden your knowledge horizon.

 Azure Cosmos DB

What is Azure Cosmos DB?

Azure Cosmos DB is Microsoft’s globally distributed, multi-model database service. It is a fully managed NoSQL database for modern app development. It guarantees speed at any scale given the single-digit millisecond response times and automatic and instant scalability. Also, it assures business continuity with SLA-backed availability and enterprise-grade security. Moreover, with this service App development is quicker and more productive given the turnkey multi region data distribution anywhere in the world, open source APIs and SDKs for popular languages. It also manages capacity with cost-effective serverless and automatic scaling options that respond to application needs to balance capacity with demand.

Features of Azure Cosmos DB

Azure Cosmos DB comes with a plethora of capabilities. Understanding Cosmos DB features like multi-model, multi-API, and various levels of consistency levels can help you choose the best API and model for your application. Let us have a look at them :

Distributes Globally

Your data replicates globally with Azure Cosmos DB by adding Azure regions with just one click.

Linearly Scalable

The ability to manage increased load by adding more servers to the cluster is referred to as linear scalability. Cosmos DB can handle hundreds of millions of read and write transactions per second.

Schema-Agnostic Indexing

The database engine in Cosmos DB is schema-agnostic, which allows for automated data indexing. Cosmos DB indexes all the data without the need for schema or index management.

Multi-API and Multi-Language Support

SDKs for a variety of programming languages have been released by Microsoft, including Java, .NET, Python, Node.js, JavaScript, and others. The SQL API, Cosmos DB Table API, MongoDB API, Graph API, Cassandra API, and Gremlin API are all supported by Cosmos DB.

Multi-Model

Cosmos DB is a multi-model database, which means it can store data in Key-value Pair, Document-based, Graph-based, and Column Family based databases. Global distribution, provisioning throughput, horizontal partitioning, and automatic indexing capabilities are the same in all the data persistence models you select.

Automatically Indexes Data

By default, Cosmos DB indexes data on ALL fields in all documents without the need for secondary indexes, but custom indexes can still be created. Without having to identify schemas or indices in advance, Azure’s automatic indexing capability indexes every property of every record. Moreover, every data model is compatible with this feature.

Multi-Consistency Support

Cosmos DB supports 5 consistency levels, i.e., Eventual, Prefix, Session, Bounded and Strong.

High Availability

For multi-region accounts with multi-region writes, Cosmos DB offers 99.999% availability for both reads and writes. For single-region accounts, Cosmos DB offers 99.99% availability for both reads and writes. If there is a regional disaster, Cosmos DB will immediately fail over. If this is the case, the application may also failover programmatically.

Multi-Master Support

Cosmos DB supports multi-master, which ensures that writes, as well as reads, can be elastically scaled across any number of Azure regions worldwide. You may use the multi-master function to make all data servers write servers. All Azure regions now have support for Multi Master.

Ensured Low Latency

For reads and writes at all consistency speeds, Azure Cosmos DB guarantees 10 milliseconds latency at the 99th percentile. Data can be geographically spread across any number of Azure regions, allowing consumers to access their data faster by storing it closer to them. This reduces latency in retrieving the data.

Why Choose Azure Cosmos DB?

Microsoft’s Azure Cosmos DB, a multi-model database service that transparently scales and replicates your data wherever your users are, aims to help you better manage your data. Let’s take a closer look at the factors/ benefits of this service

Guaranteed speed at any scale

  • Firstly, Gain unparalleled SLA-backed speed and throughput, fast global access, and instant elasticity.
  • Secondly, Real-time access with fast read and write latencies globally, and throughput and consistency all backed by SLAs
  • Also, with a single click, you can perform multi-region writes and data distribution to any Azure region.
  • Independently and elastically scale storage and throughput across any Azure region – even during unpredictable traffic bursts – for unlimited scale worldwide.

Simplified application development

Fast, flexible app development with open source APIs, multiple SDKs, schemaless data and no-ETL analytics over operational data.

  • Fully integrated with Azure Functions, IoT Hub, AKS (Azure Kubernetes Service), App Service, and other key Azure services used in modern (cloud-native) app creation.
  • Several database APIs are available, including the native Core (SQL) API, MongoDB API, Cassandra API, Gremlin API, and Table API.
  • Build apps on Core (SQL) API using the languages of your choice with SDKs for .NET, Java, Node.js and Python. Or your choice of drivers for any of the other database APIs.
  • Run no-ETL analytics over the near-real time operational data stored in Azure Cosmos DB with Azure Synapse Analytics.
  • Change feed makes it easy to track and manage changes to database containers and create triggered events with Azure Functions.
  • The schema-less service in Azure Cosmos DB automatically indexes all of your data, regardless of the data model, to offer lightning-fast queries.

Mission-critical ready

Ready for mission-critical applications with guaranteed business continuity, 99.999-percent availability and enterprise-level security

  • Azure Cosmos DB offers a comprehensive suite of SLAs including industry-leading global availability.
  • Automated data replication allows you to easily distribute data to any Azure zone. Enjoy zero downtime with multi-region writes or RPO 0 when using Strong consistency.
  • Moreover, enjoy enterprise-grade encryption-at-rest with self-managed keys.
  • Azure role-based access control ensures the security of your data while also providing fine-tuned control.

Fully managed and cost-effective

Fully managed and cost-effective serverless database with instant, automatic scaling that responds to application needs

  • Maintenance, patching, and updates are all automated, saving developers time and resources.
  • Further, cost-effective options for unpredictable or sporadic workloads of any size or scale, enabling developers to get started easily without having to plan or manage capacity.
  • Likewise, serverless model offers spiky workloads automatic and responsive service to manage traffic bursts on demand.
  • Autoscale provisioned throughput automatically and instantly scales capacity for unpredictable workloads, while maintaining SLAs.

Azure Cosmos Databases, Containers, and Items

Databases

The Cosmos database is like a namespace, the unit of management for a set of Cosmos Containers. You will find One or more Cosmos Databases in the Cosmos account.

Containers

A Cosmos container is the unit of scalability for provisioned throughput and storage. It can scale elastically, horizontally partitioned, and then replicate across multiple Azure regions. The items added to the Container and the throughput provisioned distributes automatically across the partitions based on the partition key. 

Items

You can represent a Cosmos item as a document in a collection, row in a table, node, or edge in a graph.

Now, that we are clear with the basics, let us move towards the solutions this service offers:

Use Cases for Azure Cosmos DB

The Azure Cosmos DB services are useful and beneficial in various web, mobile, gaming, and IoT applications that need low response times and need to handle massive amounts of reads and writes.

IoT and telematics

IoT use cases commonly share some patterns in how they ingest, process, and store data.

  • Firstly, these systems need to ingest bursts of data from device sensors of various locales.
  • Secondly, these systems process and analyze streaming data to derive real-time insights.
  • After that, the data is then archived to cold storage for batch analytics.
Azure Cosmos DB IoT reference architecture
Source: Microsoft

Data ingested that needs to be processed for real-time insight can be funneled to Azure Stream Analytics for real-time analytics. For ad-hoc querying, data can be loaded into Azure Cosmos DB. Additionally, the change feed helps read new data as well as updates to existing data. Change feed is a p persistent, append-only log that stores sequential changes to Cosmos containers. Then all data or just changes to data in Azure Cosmos DB can be used as reference data as part of real-time analytics. 

Retail and marketing

Microsoft’s own e-commerce services, such as the Windows Store and XBox Live, depend heavily on Azure Cosmos DB. In the retail industry, it’s also for storing catalog data and for event sourcing in order processing pipelines. Azure Cosmos DB supports flexible schemas and hierarchical data, making it ideal for storing product catalogue data.

Source: Microsoft

With its change feed functionality, Azure Cosmos DB is frequently used for event sourcing to power event driven architectures. The change feed provides downstream microservices the ability to reliably and incrementally read inserts and updates (for example, order events) made to an Azure Cosmos DB. 

Gaming

Modern games use mobile/console clients for graphical processing, but the cloud is used to provide tailored and personalised content such as in-game stats, social media integration, and high-score leaderboards. Games like The Walking Dead: No Man’s Land by Next Games and Halo 5: Guardians use Azure Cosmos DB.

Azure Cosmos DB gaming reference architecture
Source: Microsoft

Game developers benefit from Azure Cosmos DB in the following ways:

  • To begin with, Azure Cosmos DB allows performance to be scale up or down elastically.  This allows games to update the profiles and stats of hundreds of thousands of players at the same time with a single API call.
  • Then, Azure Cosmos DB supports millisecond reads and writes for reducing lags in gameplay.
  • Moreover, Automated indexing in Azure Cosmos DB allows for real-time filtering against multiple different properties, such as locating players by their internal player IDs, GameCenter, Facebook, or Google IDs, or querying based on guild membership. This is possible without the use of costly indexing or sharding infrastructure.
  • Further, Azure Cosmos DB as a managed platform-as-a-service (PaaS) required minimal setup and management, allowing for faster iteration and shorter time to market.

Web and mobile applications

Azure Cosmos DB is popular within web and mobile applications and is ideal for modeling social interactions, integrating with third-party services, and for building rich personalized experiences. Cosmos DB SDKs can also create rich iOS and Android apps using the popular Xamarin framework.

Furthermore, a common use case for Azure Cosmos DB is to store and query user generated content (UGC) for web, mobile, and social media applications. Chat sessions, tweets, blog entries, reviews, and comments are all examples of user-generated content.

Summing Up

Microsoft’s Azure Cosmos DB, a multi-model storage service that transparently scales and replicates the data wherever your users are, aims to help you properly manage your data. It helps enterprises establish a flexible database that would help them meet their business needs. Latency is minimum and your users have a faster and more seamless experience. Therefore, Azure Cosmos DB is a good fit for any serverless application that requires response times in milliseconds and needs to scale quickly and globally.

Azure Cosmos DB online tutorials

Upgrade your knowledge with Online Tutorials for Azure Cosmos DB Now!

Menu