Azure Cosmos DB — Global NoSQL Database
Build globally distributed apps with Cosmos DB — single-digit ms latency, multi-region writes, and multiple APIs.
“Welcome back. Today we're exploring Azure Cosmos DB — one of the most powerful and unique databases in the world. Cosmos DB is designed for applications that need single-digit millisecond response times, anywhere in the world, at any scale. It powers some of the largest applications on the planet, including major parts of Microsoft's own infrastructure. Let's understand what makes it special.”
“Cosmos DB is Microsoft's globally distributed, multi-model database. It stores data in a schema-agnostic way and guarantees single-digit millisecond response times — not average, but at the 99th percentile. You can replicate your data to any of Azure's 60+ regions with a single click. The 99.999% availability SLA for multi-region configurations means less than 5 minutes of downtime per year. This is the database for applications where latency and availability are non-negotiable.”
“One of Cosmos DB's unique features is its multi-API support. The same underlying engine can be accessed through five different APIs. Core SQL is the native API — stores JSON documents and supports a SQL-like query language. If you have an existing MongoDB application, the MongoDB API means you can use Cosmos DB as a drop-in replacement without changing your application code. This flexibility lets you choose the right data model without switching databases.”
“Data in Cosmos DB is organized into containers, similar to collections in MongoDB or tables in SQL. Each container is infinitely scalable because Cosmos DB automatically partitions your data across multiple physical servers. The partition key is the most important design decision — it determines how your data is distributed. A good partition key has high cardinality — many distinct values — and distributes your read and write load evenly. User ID is often a great partition key for user-centric applications.”
“Cosmos DB uses Request Units as the currency for database operations. One RU is the cost to read a 1 kilobyte document. Writes cost more — typically around 5 RUs for the same document. You provision a throughput in RUs per second for your container. If your queries need more RUs than provisioned, they get throttled. Autoscale mode automatically scales throughput up and down based on demand, between a minimum and maximum you define — perfect for unpredictable workloads.”
“Consistency in distributed databases is a trade-off between freshness, latency, and availability. Cosmos DB gives you five levels to tune this trade-off. Strong consistency means every read sees the latest write — but adds latency because the write must reach all replicas before returning. Eventual consistency gives maximum performance but reads might see slightly stale data. Session consistency — the default — is perfect for most apps: within your session, reads always see your own writes.”
“Global distribution is where Cosmos DB truly shines. You can add any Azure region as a replica with a single click or API call — no manual replication setup. Traffic Manager automatically routes users to the nearest region, minimizing latency. With multi-region writes enabled, users anywhere in the world write to their local replica and Cosmos DB handles replication and conflict resolution automatically. This is how you build truly global applications with consistently low latency for every user.”
“Let's create a Cosmos DB account and explore it. I'll set up a container with a partition key, insert some JSON documents in the Data Explorer, and run SQL queries against them. Then I'll add a read replica region to show how easy global distribution is, and check the RU consumption metrics to understand the cost of our operations. This will give you a real feel for how Cosmos DB works in practice.”
“Cosmos DB is the database for planet-scale, globally distributed applications. The combination of global replication, tunable consistency, and multiple APIs makes it uniquely powerful. Next we cover Azure Key Vault — the secure vault for secrets, certificates, and encryption keys. If you're putting passwords in config files or environment variables, Key Vault is the solution. See you in the next one.”
- 1Create a Cosmos DB account (Core SQL API)
- 2Create a database and container with partition key
- 3Insert documents via Data Explorer
- 4Run SQL queries against documents
- 5Add a second read region
- 6Show consistency level settings
- 7View Request Units (RU) consumption