Cosmos DB is Azure’s globally distributed, multi-model database. It’s different from SQL Server in fundamental ways. Here’s what you need to know to get started.
Key Concepts
- Global distribution: Replicate data across regions with a click
- Multi-model: Document, key-value, graph, column-family APIs
- Guaranteed latency: <10ms reads/writes at 99th percentile
- Elastic scale: Throughput and storage scale independently
Request Units (RU/s)
Cosmos DB pricing is based on Request Units. Think of it as a normalized measure of throughput:
1 RU = 1 KB document read
~5 RUs = 1 KB document write
Complex queries = more RUs.NET Example
var client = new CosmosClient(connectionString);
var container = client.GetContainer("mydb", "items");
// Create
await container.CreateItemAsync(item, new PartitionKey(item.Category));
// Read
var response = await container.ReadItemAsync- (id, new PartitionKey(category));
When to Use It
- Global applications needing low latency everywhere
- High-throughput scenarios (IoT, gaming)
- Document-oriented data models
References
Discover more from C4: Container, Code, Cloud & Context
Subscribe to get the latest posts sent to your email.