Cosmos DB Architecture
Develop for Azure Storage
Shahzad Mian
Content developer, DataCamp
Azure Cosmos DB
The problem
What is Cosmos DB?
Multi-model, globally distributed NoSQL database.
NoSQL - flexible, folder-like storage.
Supports multiple APIs and data types.
Like a flexible restaurant menu - choose your API flavor:
SQL (Core) for JSON documents.
MongoDB for Mongo developers.
Cassandra for wide-column data.
Gremlin for graph relationships.
Table API for key-value storage.
Cosmos DB for developers
Built with developers in mind.
Automatic indexing - no schema management.
Fast queries.
Five consistency levels: from Strong to Eventual.
Trade-off between performance vs consistency.
Strong - everyone hears the same message instantly.
Eventual - everyone catches up later.
Scaling and Throughput (RU/s)
Request units per second (RU/s) = performance currency of Cosmos DB.
Each read, write, or query spends some RU/s.
Choose fixed provisioning or autoscale.
Scaling and Throughput (RU/s)
Request units per second (RU/s) = performance currency of Cosmos DB.
Each read, write, or query spends some RU/s.
Choose fixed provisioning or autoscale.
Autoscale adjusts automatically with demand.
Elastic scale and Partitioning
Cosmos DB scales through partitioning.
Each container uses a partition key.
The key groups related data together.
Example: Cipher Coffee uses
/customerId
for orders.
All a customer's orders live in the same partition when using
/customerId
as the partition key.
Queries stay fast even as data grows.
Hot partition
: Uneven partition load slowing down performance.
Global distribution
Replicate data to any Azure region easily.
Just tick checkboxes, no setup hassle.
If one region fails, traffic reroutes automatically.
No downtime, no data loss.
Like a backup cafe ready to serve customers instantly.
Monitoring and cost optimization
Track performance in the Azure Portal.
View metrics like RU/s, latency, and request charge.
Like a car dashboard - see speed and fuel use.
Cipher Coffee engineers analyzed these metrics.
Reduced costs by adjusting throughput dynamically.
Let's practice!
Develop for Azure Storage
Preparing Video For Download...