Concepts of Cosmos DB: Request Unit
Tags: azure, database, cosmosdb
Published: 2024-02-05 13:32:25

After the [introduction of Cosmos DB](https://dev.to/mariustechie/embarking-on-a-data-odyssey-a-comprehensive-introduction-to-cosmos-db-2loi) and [understanding the various way of scaling the "traditional" databases](https://dev.to/mariustechie/navigating-the-database-scaling-landscape-understanding-vertical-and-horizontal-scaling-strategies-4i8e) I would like to continue writing about **Request Unit**, a fundamental topic for pricing and capacity planning in Cosmos DB.

## What is a Request Unit (RU)?

According to Microsoft, a Request Unit [is a performance currency abstracting the system resources such as CPU, IOPS, and memory that are required to perform the database operations supported by Azure Cosmos DB. Whether the database operation is a write, point read, or query, operations are always measured in RUs](https://learn.microsoft.com/en-us/azure/cosmos-db/request-units).

In simpler terms, **RU** in Azure Cosmos DB is a measure of the amount of resources required to perform operations on the database. It is a unit that combines the cost of reading and writing data, as well as other database operations like indexing. <u>This is how Azure Cosmos DB charges for database operations</u>. Microsoft defines <u>1 RU = 1 point read of 1kb</u>. 

So, when you make a request to the Cosmos DB database, the number of Request Units needed depends on the complexity and amount of data involved in that operation. For example, a simple read operation might cost fewer Request Units than a complex query or a write operation that involves a lot of data.

###Monitoring and Optimization

The Azure Portal provides tools for monitoring the consumption of Request Units for your Cosmos DB account. You could use <u>Azure Monitor</u> <u>Metrics</u> or <u>Diagnostic Logs</u>. Efficient monitoring of these resources guarantees availability, performance (identify and address bottlenecks and inefficiencies in real time) and functionality. Monitoring can be used to optimize queries, indexes, and data models for better performance and cost efficiency (resources are allocated efficiently, reducing unnecessary costs).

In summary, **Request Units** are a way to quantify the cost of operations in Azure Cosmos DB, helping you understand and manage the resource consumption of your database.

In the next article, I will cover another import concept of Cosmos DB: **Provisioned Throughput**.  You can provision a certain amount of **RU/s** (Request Units per second) for a container based on your anticipated workload.

Photo by <a href="https://unsplash.com/@shubzweb3?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Shubham's Web3</a> on <a href="https://unsplash.com/photos/a-group-of-purple-cubes-hanging-from-a-metal-bar-lY0-Y3kX5ps?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a>

P.S.

I would love hearing from our tech-savvy community! Have insights, tips, or burning questions? Don't keep them to yourself! Drop your thoughts in the comments below. Let's spark a conversation and learn from each other's experiences in the dynamic world of Azure migration