Plan and manage costs for Azure Cosmos DB
APPLIES TO: SQL API Cassandra API Gremlin API Table API Azure Cosmos DB API for MongoDB
This article describes how you can plan and manage costs for Azure Cosmos DB. First, you use the Azure Cosmos DB capacity calculator to estimate your workload cost before you create any resources. Later you can review the estimated cost and start creating your resources.
After you've started using Azure Cosmos DB resources, use the Cost Management features to set budgets and monitor costs. You can also review forecasted costs and identify spending trends to identify areas where you might want to act. The costs for Azure Cosmos DB are only a portion of the monthly costs in your Azure bill. Although this article explains how to plan for and manage costs for Azure Cosmos DB, you're billed for all Azure services and resources used in your Azure subscription, including the third-party services.
Provisioned throughput or serverless
Azure Cosmos DB supports two types of capacity modes: provisioned throughput and serverless. The way you get charged for your Azure Cosmos DB usage varies a lot between these two modes, so it's important to choose the one that works best for your workload. See the how to choose between provisioned throughput and serverless article for guidance and recommendations on how to make this choice.
Cost analysis in Cost Management supports most Azure account types, but not all of them. To view the full list of supported account types, see Understand Cost Management data. To view cost data, you need at least read access for an Azure account. For information about assigning access to Azure Cost Management data, see Assign access to data.
Estimating provisioned throughput costs before using Azure Cosmos DB
If you plan to use Azure Cosmos DB in provisioned throughput mode, use the Azure Cosmos DB capacity calculator to estimate costs before you create the resources in an Azure Cosmos account. The capacity calculator is used to get an estimate of the required throughput and cost of your workload. Configuring your Azure Cosmos databases and containers with the right amount of provisioned throughput, or Request Units (RU/s), for your workload is essential to optimize the cost and performance. You have to input details such as API type, number of regions, item size, read/write requests per second, total data stored to get a cost estimate. To learn more about the capacity calculator, see the estimate article.
The following screenshot shows the throughput and cost estimation by using the capacity calculator:
Estimating serverless costs before using Azure Cosmos DB
If you plan to use Azure Cosmos DB in serverless mode, you need to estimate how many Request Units and GB of storage you may consume on a monthly basis. You can estimate the required amount of Request Units by evaluating the number of database operations that would be issued in a month, and multiply their amount by their corresponding RU cost. The following table lists estimated RU charges for common database operations:
|Create an item||5 RUs||Average cost for a 1 KB item with less than 5 properties to index|
|Update an item||10 RUs||Average cost for a 1 KB item with less than 5 properties to index|
|Read an individual item by its ID and partition key (point-read)||1 RU||Average cost for a 1 KB item|
|Delete an item||5 RUs|
|Execute a query||10 RUs||Average cost for a query that takes full advantage of indexing and returns 100 results or less|
Pay attention to the Notes from the table above. For a more accurate estimation of the actual costs of your operations, you can use the Azure Cosmos DB Emulator and measure the exact RU cost of your operations. Although the Azure Cosmos DB Emulator doesn't support serverless, it reports a standard RU charge for database operations and can be used for this estimation.
Once you have computed the total number of Request Units and GB of storage you're likely to consume over a month, the following formula will return your cost estimate: ([Number of Request units] / 1,000,000 * $0.25) + ([GB of storage] * $0.25).
The costs shown in the previous example are for demonstration purposes only. See the pricing page for the latest pricing information.
Review estimated costs in the Azure portal
As you start using Azure Cosmos DB resources from Azure portal, you can see the estimated costs. Use the following steps to review the cost estimate:
Sign into the Azure portal and navigate to your Azure Cosmos account.
Go to the Overview section.
Check the Cost chart at the bottom. This chart shows an estimate of your current cost over a configurable time period:
Create a new container such as a graph container.
Input the throughput required for your workload such as 400 RU/s. After you input the throughput value, you can see the pricing estimate as shown in the following screenshot:
If your Azure subscription has a spending limit, Azure prevents you from spending over your credit amount. As you create and use Azure resources, your credits are used. When you reach your credit limit, the resources that you deployed are disabled for the rest of that billing period. You can't change your credit limit, but you can remove it. For more information about spending limits, see Azure spending limit.
You can pay for Azure Cosmos DB charges with your Azure Prepayment (previously called monetary commitment) credit. However, you can't use the Azure Prepayment credit to pay for charges for third party products and services including those from the Azure Marketplace.
As you use resources with Azure Cosmos DB, you incur costs. Resource usage unit costs vary by time intervals (seconds, minutes, hours, and days) or by request unit usage. As soon as usage of Azure Cosmos DB starts, costs are incurred and you can see them in the cost analysis pane in the Azure portal.
When you use cost analysis, you can view the Azure Cosmos DB costs in graphs and tables for different time intervals. Some examples are by day, current, prior month, and year. You can also view costs against budgets and forecasted costs. Switching to longer views over time can help you identify spending trends and see where overspending might have occurred. If you’ve created budgets, you can also easily see where they exceeded.
To view Azure Cosmos DB costs in cost analysis:
Sign into the Azure portal.
Open the scope in the Azure portal and select Cost analysis in the menu. For example, go to Subscriptions, select a subscription from the list, and then select Cost analysis in the menu. Select Scope to switch to a different scope in cost analysis.
By default, cost for all services are shown in the first donut chart. Select the area in the chart labeled "Azure Cosmos DB".
To narrow costs for a single service such as Azure Cosmos DB, select Add filter and then select Service name. Then, choose Azure Cosmos DB from the list. Here’s an example showing costs for just Azure Cosmos DB:
In the preceding example, you see the current cost for Azure Cosmos DB for the month of Feb. The charts also contain Azure Cosmos DB costs by location and by resource group.
You can create budgets to manage costs and create alerts that automatically notify stakeholders of spending anomalies and overspending risks. Alerts are based on spending compared to budget and cost thresholds. Budgets and alerts are created for Azure subscriptions and resource groups, so they're useful as part of an overall cost monitoring strategy.
Budgets can be created with filters for specific resources or services in Azure if you want more granularity present in your monitoring. Filters help ensure that you don't accidentally create new resources that cost you additional money. For more about the filter options when you when create a budget, see Group and filter options.
Export cost data
You can also export your cost data to a storage account. This is helpful when you need or others to do additional data analysis for costs. For example, a finance teams can analyze the data using Excel or Power BI. You can export your costs on a daily, weekly, or monthly schedule and set a custom date range. Exporting cost data is the recommended way to retrieve cost datasets.
See the following articles to learn more on how pricing works in Azure Cosmos DB:
- Pricing model in Azure Cosmos DB
- Optimize provisioned throughput cost in Azure Cosmos DB
- Optimize query cost in Azure Cosmos DB
- Optimize storage cost in Azure Cosmos DB
- Learn how to optimize your cloud investment with Azure Cost Management.
- Learn more about managing costs with cost analysis.
- Learn about how to prevent unexpected costs.
- Take the Cost Management guided learning course.