Azure Cosmos DB: Architecture and APIs
What you'll learn: How Azure Cosmos DB's flexible architecture supports multiple database APIs under one service.
What Makes Cosmos DB Different
Azure Cosmos DB is a globally distributed, multi-model database service. Think of it as a universal database adapter — one platform that speaks multiple database "languages." Unlike DynamoDB (which you just learned) with its single NoSQL API, Cosmos DB lets you choose how you want to interact with your data using different APIs, all backed by the same underlying storage engine.
The Multi-Model Architecture
Cosmos DB stores data in a format called Atom-Record-Sequence (ARS). This flexible internal representation allows the same data to be accessed through different APIs:
- SQL (Core) API: Query using familiar SQL-like syntax — the default and most feature-rich option
- MongoDB API: Compatible with MongoDB drivers and tools — migrate existing MongoDB apps without code changes
- Cassandra API: Works with Apache Cassandra clients — column-family data model
- Gremlin API: For graph databases — nodes, edges, and relationships
- Table API: Key-value pairs — similar to Azure Table Storage but globally distributed
Why Multiple APIs Matter
Imagine you have a MongoDB application but want Cosmos DB's global distribution. With the MongoDB API, you point your existing app at Cosmos DB with minimal changes. Need to add graph queries later? Your same data becomes accessible via Gremlin API.
Each API maps onto the same underlying partitioned, replicated storage, inheriting Cosmos DB's strengths: global distribution, automatic indexing, and guaranteed performance SLAs.
Choosing Your API
Pick based on your application's data model and query patterns, not the storage engine. The API choice is made at container creation and cannot be changed later.
Key Takeaway: Azure Cosmos DB provides five different APIs (SQL, MongoDB, Cassandra, Gremlin, Table) over one globally distributed storage platform, letting you pick the best data model for your application while getting consistent enterprise features.