Price Differences for Azure Cosmos DB Provisioned or Serverless Throughput Cost

By:   |   Updated: 2022-04-07   |   Comments   |   Related: > Azure Cosmos DB


Problem

Azure Cosmos DB default provisioned throughput mode configures a fixed capacity of request units (RUs) and charges you for the allocated cost. However, what would you do if you have a volatile workload and do not want recurring costs for high scalable resources? Let's explore the Azure Cosmos DB Serverless mode in this tutorial.

Solution

Azure Cosmos DB is a hyper-scale, fully managed, multi-model, Platform-as-a-Service Azure NoSQL Database. It's exciting features are Globally Distributed, Linear Scalability, and High Availability.

It allows you to configure the provisioned throughput for your databases and containers. The Azure Cosmos DB serverless mode uses the consumption-based model and charges the Request Units (RUs) and storage consumed. Therefore, you do not have any capacity planning, and your application can serve thousands of requests with no upfront cost for high capacity.

The Azure Cosmos DB Serverless configuration is suitable for unpredictable and intermittent workloads. We can use it for development, staging, or test servers or small applications.

Creating Serverless Instance of Azure Cosmos DB

Let's deploy an Azure Cosmos DB Serverless instance in this tip. I assume you have an Azure subscription with the privilege to create a new Azure Cosmos DB.

Launch the Azure portal and search for the Azure Cosmos DB service.

azure cosmos db service

Click on create to start the creation of a new Cosmos DB account. First, choose the API option from the below options:

  • Core SQL
  • Azure Cosmos DB API for MongoDB
  • Cassandra
  • Azure Table
  • Gremlin(Graph)
select azure cosmos db api

Let's choose Core(SQL) and click on Create for this tip.

Basics

The basic configuration asks for the following details for a new Cosmos DB account.

  • Azure subscription
  • Resource group: Choose your existing resource group from the drop-down or specify a name for the new resource group.
create azure cosmos db account

You need to specify the cosmos DB account name and its location in the instance details. As shown below, the default capacity mode is provisioned throughput.

If you have any queries on capacity mode, click on the hyperlink – Learn more about the capacity mode that redirects you to Microsoft documentation.

create azure cosmos db account

Click on the Serverless capacity mode as shown below.

create azure cosmos db account basics

Global Distribution

We can configure the global distribution and regional setting for the Cosmos DB account. By default, it is disabled.

create azure cosmos db account global distribution

Networking

The networking section requires choosing the connectivity method. You can choose either the public endpoint, the private endpoint, or all networks. The default setting is all networks which is fine for this tip. However, you can choose a specific network, especially for the production environment.

Note: Do not use option – All networks in the production Cosmos DB accounts from the security point of view.

create azure cosmos db account networking

Backup Policy

The backup policy can be either Periodic or Continuous. We already covered the difference between these policies in the existing published tips on Cosmos DB.

create azure cosmos db account backup policy

I skipped Encryption and Tags as these are not relevant for this tip. In the Review + create page, review your Azure Cosmos DB account – Core (SQL) API configurations. The below image shows validation success. Therefore, we can click on Create to start deploying the customized configuration.

create azure cosmos db account summary

Once the Cosmos DB account is created, the dashboard shows capacity mode serverless, as shown below.

create azure cosmos db account

You can add a new container to the serverless capacity account. It won't ask the details such as throughput manual or autoscale.

create azure cosmos db new container

Cost Comparison of Azure Cosmos DB provisioned throughput and Serverless

To get a comparison in terms of the cost of provisioned throughput and serverless mode, we can use a pricing calculator. You can launch the pricing calculator from this URL - https://azure.microsoft.com/en-in/pricing/calculator/.

Provisioned throughput cost

Let's assume you have the following configuration for provisioned throughput Cosmos DB account:

  • Request unit per second: 500 request units per second
  • Total(Maximum) RUs in a month(720 hours): 1296,000,000
  • Your target consumption: 20,000,000

Therefore the cost as per the pricing calculator will be as below:

  • A = The price per 100 RU/s per hour = $ 0.008
  • B = Total number of hours = 720 hours
  • C = 500 Request units per seconds

Cost for provisioned throughput = USD (A* B* C )/100

  • = 0.008*720*500
  • = $28.80
create azure cosmos db costs

The cost in provisioned throughput is constant for request units per second. However, the price in serverless capacity is dependent on the million request unit costs.

Serverless throughput cost

The Serverless Cosmos DB calculates costs per million request units. For example, it costs $0.25 for 1 million RUs in East US.

Serverless tier also costs for transactional storage apart from the request units. It charges $0.250 per GB \month.

create azure cosmos db costs

If we increase the consumed request units in serverless capacity with 20million RUs, the cost in East US is $50.00

create azure cosmos db costs

Note: We have not considered the storage cost in both provisioned and serverless capacity. The storage cost is the same in both modes.

Comparison between Provisioned throughput and Serverless mode

  Provisioned throughput Serverless
Configurations It defines request unit per second (RUs) throughput. Every second, the configured RUs are available for database activity. It does not use any provisioned capacity. It charges based on RUs consumed.
Scaling Manual or Autoscale Autoscale
Geo-distribution Available (unlimited number of Azure regions) It supports only run in 1 Azure region
Maximum storage per container Unlimited 50 GB
Performance < 10 ms latency for point-reads < 10 ms latency for writes covered by SLA < 10 ms latency for point-reads < 30 ms for writes covered by SLO
Billing model Per-hour basis for the RU/s provisioned. Per-hour basis for the consumed RUs
Next Steps


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Rajendra Gupta Rajendra Gupta is a Consultant DBA with 14+ years of extensive experience in database administration including large critical OLAP, OLTP, Reporting and SharePoint databases.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips


Article Last Updated: 2022-04-07

Comments For This Article

















get free sql tips
agree to terms