Azure Cosmos DB Documentation

Frequently Asked Questions

General Questions

What is Azure Cosmos DB?
Azure Cosmos DB is a globally distributed, multi-model database service that enables you to rapidly create and query document, key-value, and graph databases. It offers guaranteed low latency, high availability, and elastic scalability, making it ideal for a wide range of modern applications.
What are the core features of Cosmos DB?
  • Global Distribution: Turn on any number of Azure regions with a single click.
  • Multi-model Data: Supports document, key-value, graph, and column-family data.
  • Guaranteed Throughput and Latency: Offers predictable performance with SLAs.
  • Elastic Scalability: Scales throughput and storage up and down as needed.
  • Five Consistency Models: Choose from strong, bounded staleness, session, consistent prefix, or eventual consistency.
  • APIs: Supports SQL (Core), MongoDB, Cassandra, Gremlin, and Table APIs.
What is RU/s?
RU/s stands for Request Units per second. It's a normalized measure of throughput that represents the cost of various database operations. Cosmos DB uses RU/s to abstract the complexity of underlying hardware resources like CPU, memory, and IOPS. You provision RU/s to guarantee the performance of your application.

API Specific Questions

Can I migrate my existing MongoDB database to Cosmos DB?
Yes, Azure Cosmos DB offers a MongoDB API that allows you to leverage your existing MongoDB applications and drivers with Cosmos DB. You can migrate your data and applications without significant code changes.
How does the Gremlin API work?
The Gremlin API in Azure Cosmos DB is designed for graph databases. It supports the Apache TinkerPop Gremlin traversal language, allowing you to build and query rich graph data structures efficiently. It's ideal for scenarios like social networks, recommendation engines, and fraud detection.

Performance and Scalability

How do I optimize throughput for my Cosmos DB container?
Optimizing throughput involves several strategies:
  • Choose the right partition key: A good partition key distributes requests evenly and avoids hot partitions.
  • Tune RU/s provisioning: Scale your RU/s based on actual workload demands, using autoscale where appropriate.
  • Optimize queries: Use indexing policies effectively and write efficient queries.
  • Batch operations: For bulk inserts or updates, consider using the bulk operations library.
For more details, refer to the Cosmos DB performance optimization guide.
What is partitioning in Cosmos DB?
Partitioning is the mechanism by which Azure Cosmos DB distributes data across multiple logical and physical partitions. A logical partition is a subset of data that shares the same partition key value. A physical partition hosts one or more logical partitions. Proper partitioning is crucial for scalability and performance.

Pricing and Cost Management

How is Cosmos DB pricing calculated?
Cosmos DB pricing is based on two main components:
  • Throughput: You pay for the provisioned Request Units (RU/s) per hour.
  • Storage: You pay for the amount of data stored in your database.
There are also costs associated with features like backups and regions. You can use the Azure Cosmos DB pricing calculator to estimate costs.
What are the benefits of using autoscale?
Autoscale allows Cosmos DB to automatically scale the throughput (RU/s) of your database or container based on demand. This ensures you have the necessary performance during peak times and saves costs by scaling down during idle periods. It's ideal for unpredictable workloads.