Internative Logo

What Is Azure Cosmos DB? Microsoft's Globally Distributed Database

What Is Azure Cosmos DB? Microsoft's Globally Distributed Database

An application with users on several continents runs into physics. A database in one region means every request from the other side of the world crosses an ocean, and an outage in that region takes the whole product down. Copying data to several regions solves both problems, but keeping those copies consistent, failing over automatically and scaling each region independently is hard engineering. Azure Cosmos DB is Microsoft's managed answer to that problem: a database you add regions to with a setting, not a project.

This article explains what Azure Cosmos DB is, how its partitioning, request units and consistency levels work, where it fits, where it does not, and how it compares with other managed NoSQL databases.

What is Azure Cosmos DB?

Azure Cosmos DB is a fully managed, globally distributed NoSQL database service on Microsoft Azure. It stores JSON documents and other data models, replicates them to any Azure regions you choose, and backs latency, throughput, consistency and availability with service-level agreements. Microsoft now also positions it as a vector database for AI applications, with vector search built in.

The project started inside Microsoft in 2010 under the name Project Florence, to solve scaling problems in Microsoft's own internet-scale services. It was first offered to customers as Azure DocumentDB, a document database, and on 10 May 2017 Microsoft relaunched it at its Build conference as Azure Cosmos DB, a multi-model service with global distribution at its core.

Cosmos DB is a proprietary service that runs only on Azure. For local development and testing there is a free emulator.

How Cosmos DB works

Accounts, databases, containers and items. A Cosmos DB account holds databases; a database holds containers; a container holds items, which in the native API are JSON documents. Throughput can be assigned to a database or to an individual container.

Partition keys. Every container has a partition key, such as a customer ID or a tenant ID. Items with the same key form a logical partition, and Cosmos DB spreads logical partitions across physical partitions as data and traffic grow. Queries that include the partition key go straight to one partition; queries that do not have to fan out across all of them. The partition key cannot be changed later without moving the data to a new container, so it is the most important design decision.

Request units. Throughput is measured in request units (RU), a single currency that covers CPU, memory and I/O. A point read of a small item costs about one RU; writes, indexing and complex queries cost more. You can provision a fixed number of RU per second, let autoscale move between limits, or use the serverless mode and pay per request.

Five consistency levels. Instead of a choice between strong and eventual, Cosmos DB offers five: strong, bounded staleness, session, consistent prefix and eventual. Session consistency, the default, guarantees that a client reads its own writes, which is what most applications need.

Global distribution. You add or remove Azure regions on a live account. Data replicates automatically, applications read from the nearest region, and failover is automatic. With multi-region writes, every region accepts writes.

Key features

  • Multiple APIs: the native API for NoSQL, plus APIs compatible with MongoDB, Apache Cassandra, Apache Gremlin (graph) and Azure Table, and a distributed PostgreSQL option.
  • Automatic indexing: every property is indexed by default, so new query patterns rarely need schema work.
  • SLA-backed availability: up to 99.999% availability for multi-region accounts, according to Microsoft's documentation.
  • Change feed: an ordered stream of changes that drives Azure Functions, event processing and data pipelines.
  • Vector and hybrid search: embeddings stored next to operational data, indexed with DiskANN, for retrieval-augmented generation and AI agents.
  • Analytics without ETL: mirroring into Microsoft Fabric or Azure Synapse Link for near real-time analysis.

Where Cosmos DB is used

  • Global web and mobile applications that need low latency for users in several regions.
  • SaaS platforms, where a tenant ID makes a natural partition key and hierarchical partition keys help with very large tenants.
  • Retail and e-commerce: catalogues, carts and orders that must stay available during peaks.
  • IoT and telemetry: device state and event data, processed through the change feed.
  • AI applications: chat history, agent memory and vector search. Microsoft states that OpenAI relies on Cosmos DB to scale ChatGPT.

When to choose Cosmos DB, and when not to

Choose Cosmos DB when:

  • The system runs on Microsoft Azure and should stay within Azure's security, identity and networking model.
  • Users are spread across regions and need low latency and high availability everywhere.
  • Data is document-shaped, and most queries can include a clear partition key.
  • Traffic is uneven and you want managed scaling, from serverless to very large provisioned throughput.
  • You are moving an existing MongoDB or Cassandra application to a managed Azure service.

Look elsewhere when:

  • The application is highly relational, with joins and multi-table transactions. Microsoft itself points such workloads to Azure SQL; Microsoft SQL Server and PostgreSQL fit them better.
  • The main workload is analytical: large scans, aggregations and reports. Cosmos DB is built for operational data; analytics belong in Fabric or a data warehouse.
  • Queries rarely know the partition key. Cross-partition queries consume many request units and costs become hard to predict.
  • The system must be portable across clouds or run on-premise. Cosmos DB exists only on Azure.

Cosmos DB and its alternatives

DatabaseModelWhere it runsBest fit
Azure Cosmos DBMulti-model NoSQL, vectorAzure onlyGlobally distributed apps on Azure
Amazon DynamoDBKey-value and documentAWS onlyKey-based access at scale on AWS
MongoDB AtlasDocumentAWS, Azure, Google CloudRich document queries, multi-cloud
Apache CassandraWide-columnAnywhereWrite-heavy, multi-region, self-managed
Azure SQL / SQL ServerRelationalAzure, on-premiseRelational data, joins and transactions

The two most common comparisons are with SQL Server and with MongoDB. Cosmos DB vs SQL Server is a choice between data models: SQL Server is relational, with schemas, joins and transactions across tables, while Cosmos DB trades those for horizontal scale, schema flexibility and turnkey global distribution. Cosmos DB vs MongoDB is closer. MongoDB offers a richer query and aggregation language and runs on any cloud, while Cosmos DB offers SLA-backed global distribution inside Azure; its MongoDB-compatible API lets existing MongoDB drivers connect to it.

On AWS, the equivalent service is Amazon DynamoDB. Apache Cassandra offers similar multi-region resilience without tying you to one provider, at the cost of running it yourself.

How we use Cosmos DB at Internative

We use Azure Cosmos DB for applications that need global reach, low-latency access and elastic scaling. Its support for several data models and its integration with other Azure services make it a good fit for enterprise cloud architectures built on Azure.

If you are building a new product on Azure or moving an existing system there, our cloud architecture and migration team can help you decide whether Cosmos DB and its partitioning model fit your data.

Frequently asked questions

What is Azure Cosmos DB used for?

Cosmos DB is used for operational data in applications that need low latency and high availability across regions: web and mobile backends, SaaS platforms, e-commerce, IoT, gaming and, increasingly, AI applications that store chat history and vector embeddings next to their business data.

Is Cosmos DB SQL or NoSQL?

Cosmos DB is a NoSQL database. Its native API, called API for NoSQL, stores JSON documents and lets you query them with a SQL-like syntax, but there are no joins across documents and no fixed schema. A separate PostgreSQL option exists for distributed relational workloads.

What is the difference between SQL Server and Cosmos DB?

SQL Server is a relational database with tables, schemas, joins and multi-table transactions, and it runs on-premise or in the cloud. Cosmos DB is a managed NoSQL service on Azure that stores flexible documents, scales horizontally by partition key and replicates across regions. Relational, report-heavy systems fit SQL Server; globally distributed, high-throughput applications fit Cosmos DB.

Is Cosmos DB the same as MongoDB?

No. MongoDB is a document database you can run anywhere or use as MongoDB Atlas. Cosmos DB is Microsoft's own service; it offers a MongoDB-compatible API so applications can use MongoDB drivers, but the engine, features and pricing model are different.

What is a request unit in Cosmos DB?

A request unit (RU) is the measure Cosmos DB uses for the cost of an operation, combining CPU, memory and I/O. Reading a small item by its ID and partition key costs about one RU, while writes and queries cost more. Throughput is provisioned or billed in RUs.

Related services

Where this topic becomes an engagement.

Keep reading

The articles that follow this one.