Understanding Azure Cosmos DB Storage Costs

Introduction to Storage Pricing

Azure Cosmos DB offers a fully managed NoSQL database service. Storage costs are a significant component of your overall Azure Cosmos DB spending. This document outlines how storage is billed and provides insights into managing your storage expenses.

Storage is billed based on the amount of data stored in your Azure Cosmos DB containers (collections, tables, graphs, etc.). The unit of measure is Gigabytes (GB) per month. The total storage consumed is the sum of the data size and the index size.

Factors Affecting Storage Costs

  • Data Size: The actual size of the data you store in your containers. This includes document bodies, properties, and metadata.
  • Index Size: Azure Cosmos DB automatically creates and maintains indexes for your data to ensure fast query performance. The size of these indexes contributes to your total storage consumption.
  • Data Locality: In a replicated setup, data is stored in each region. The total storage billed is the sum of storage across all regions where your database account is provisioned.
  • Data Types: While not a direct billing factor, the choice of data types and schema can influence the overall data size.

How Storage is Measured and Billed

Azure Cosmos DB measures storage consumption continuously. The total storage consumed is the maximum of:

  • The sum of the logical size of all documents in a container.
  • The sum of the size of all indexed data.

This means that even if you delete documents, if your index size is larger, you will be billed for the index size. Conversely, if your documents are larger than the indexed data, you will be billed for the document size.

Storage is billed hourly based on the provisioned storage. The calculation is (Storage in GB) * (Price per GB-hour) * (Number of hours in the month).

Storage Costs for Different APIs

The pricing for storage is consistent across all Azure Cosmos DB APIs (Core (SQL), MongoDB, Cassandra, Gremlin, Table). The cost is primarily determined by the amount of data stored and the chosen region.

Estimated Storage Pricing (USD per GB per month)

Note: These are indicative prices and may vary by region and subscription type. Always refer to the official Azure Cosmos DB pricing page for the most up-to-date information.

Region Group Cost per GB
North America, Europe $0.18
Asia Pacific $0.20
Other Regions $0.22

Managing Storage Costs

Best Practice: Regularly monitor your storage consumption to identify potential cost savings.
  • Partition Key Design: A well-designed partition key distributes data and requests evenly, which can indirectly help manage storage by preventing hot partitions and ensuring efficient indexing.
  • Indexing Policies: Review and optimize your indexing policies. If you don't query certain paths, consider excluding them from indexing to reduce index size.
  • Data Lifecycle Management: Implement TTL (Time To Live) to automatically expire and delete old, unneeded data.
  • Data Archiving: For data that is rarely accessed but needs to be retained, consider archiving it to a more cost-effective storage solution.
  • Compression: While Azure Cosmos DB handles internal compression, consider if your data format (e.g., JSON) can be made more concise.

Tools for Monitoring Storage

Azure Monitor and the Azure portal provide valuable tools for tracking your storage usage:

  • Azure Portal: Navigate to your Azure Cosmos DB account, then to "Metrics" to view storage usage over time.
  • Azure Monitor: Set up alerts for storage usage to proactively manage your costs.
  • SDKs and APIs: You can programmatically query for collection/container sizes and other storage-related metrics.