Azure Cosmos DB API Selection
This tutorial guides you through selecting the appropriate API for your Azure Cosmos DB workload, ensuring optimal performance, scalability, and cost-effectiveness.
Understanding Azure Cosmos DB APIs
Azure Cosmos DB is a globally distributed, multi-model database service. It supports multiple data models and APIs, allowing you to choose the one that best fits your application's needs. Each API offers different capabilities and paradigms for interacting with your data.
Core (SQL) API
The Core (SQL) API is the default and most commonly used API for Azure Cosmos DB. It provides a powerful, flexible, and familiar querying experience using a SQL-like query language. It's suitable for a wide range of applications, including web, mobile, gaming, and IoT.
- Use Cases: General-purpose NoSQL, content management, user profiles, product catalogs.
- Strengths: Rich query capabilities, schema-agnostic, JSON document support.
MongoDB API
The MongoDB API allows developers to leverage their existing MongoDB skills and tools with Azure Cosmos DB. You can use your favorite MongoDB drivers and applications with Azure Cosmos DB, enjoying its global distribution, scalability, and multi-master capabilities.
- Use Cases: Migrating existing MongoDB applications, applications requiring MongoDB compatibility.
- Strengths: Familiarity for MongoDB developers, rich query language (MQL).
Cassandra API
The Cassandra API provides the Apache Cassandra wire protocol. This enables you to use your existing Cassandra applications with Azure Cosmos DB, benefiting from its managed service features like global distribution, elastic scalability, and robust SLAs without the operational overhead of managing Cassandra clusters.
- Use Cases: Time-series data, IoT data, large-scale event logging, applications built on Cassandra.
- Strengths: High availability, high throughput, linear scalability, familiar CQL (Cassandra Query Language).
Gremlin API
The Gremlin API offers a graph database experience, enabling you to work with highly connected data. It uses the Apache TinkerPop Gremlin query language to traverse and manipulate graph structures, ideal for scenarios like social networks, recommendation engines, and fraud detection.
- Use Cases: Social networks, fraud detection, knowledge graphs, recommendation engines.
- Strengths: Powerful graph traversal, relationship modeling, real-time insights.
Table API
The Table API offers a key-value store experience, similar to Azure Table Storage. It's optimized for storing and querying large amounts of structured, non-relational data, making it a good choice for applications that need a simple, high-performance, and cost-effective storage solution.
- Use Cases: Web application data, user data, application metadata, simple key-value storage.
- Strengths: High throughput, low latency, cost-effective, simple data model.
Choosing the Right API
The decision of which API to use depends heavily on your application's requirements, existing technology stack, and the type of data you are working with.
Factors to Consider:
- Existing Expertise: Do your developers have experience with MongoDB, Cassandra, or graph databases?
- Data Model: Are you storing documents, key-value pairs, graph data, or time-series data?
- Querying Needs: Do you require complex querying and joins (Core API) or simpler lookups and traversals?
- Compatibility: Are you migrating an existing application that relies on a specific database technology?
- Performance Requirements: Some APIs might be optimized for specific workloads.
Key Differences at a Glance
API | Data Model | Query Language | Primary Use Cases
----------------|----------------|----------------|--------------------
Core (SQL) | Document | SQL-like | General Purpose, JSON
MongoDB | Document | MQL | MongoDB Compatibility
Cassandra | Column-Family | CQL | High Throughput, IoT
Gremlin | Graph | Gremlin | Relationships, Networks
Table | Key-Value | REST/SDK | Simple Storage, High Scale
Next Steps
Once you've chosen an API, you can proceed to create your Azure Cosmos DB account and start developing your application. Refer to the specific API documentation for detailed setup and development guides.
Explore the quick start guides for each API to get hands-on experience.