Normalized RU Consumption Monitoring
Complete the full lesson to earn 25 points — 50 with Pro
Work through each section, then tap “Mark as Complete” on the last one.
✦ Skip the page breaks, the wait, and see fewer ads — read each lesson on a single page with Pro
Monitoring Normalized Request Unit (RU) Consumption in Azure Cosmos DB
Introduction: Why RU Monitoring Matters
In the world of cloud-native distributed databases, performance is not just about raw speed; it is about predictability and cost management. Azure Cosmos DB uses a unique currency called Request Units (RUs) to abstract the computational resources—CPU, IOPS, and memory—required to perform database operations. Whether you are reading a single document, performing a complex query, or executing a stored procedure, every interaction with your data consumes a specific amount of RUs.
Monitoring "Normalized RU Consumption" is the single most important activity for a database administrator or developer working with Cosmos DB. Unlike raw RU consumption, which tells you how much you used in a second, normalized consumption provides a percentage-based view of how close you are to your provisioned throughput limit. If you ignore this metric, you risk hitting rate-limiting errors (HTTP 429: Too Many Requests), which directly degrades the user experience and impacts your application’s availability. This lesson will guide you through the intricacies of normalized RU monitoring, how to interpret the data, and how to optimize your workloads to maintain a healthy, cost-effective database environment.
Understanding Request Units (RUs) and Normalization
To effectively monitor your database, you must first understand the distinction between provisioned throughput and consumed throughput. When you create a Cosmos DB container, you assign it a specific amount of throughput, measured in Request Units per second (RU/s). If your application needs to perform 1,000 operations per second, and each operation costs 5 RUs, you need to provision at least 5,000 RU/s to avoid latency spikes or throttling.
What is Normalized RU Consumption?
Normalized RU consumption is a metric that represents the average RU consumption across all physical partitions in your database or container. It is expressed as a percentage, ranging from 0 to 100.
- 0-50%: You have plenty of headroom. Your workload is well within the limits of your provisioned throughput.
- 50-80%: You are operating efficiently, but you should keep an eye on traffic spikes.
- 80-100%: You are entering the danger zone. Any unexpected traffic burst could push you over your limit, resulting in throttling.
- 100%: You have hit the limit. Any further requests will be rejected by the service until the next second begins.
The reason we use "normalized" metrics instead of raw numbers is that Cosmos DB scales by distributing data across multiple physical partitions. If one partition is overwhelmed while others are idle, you will experience throttling even if your total RU consumption across all partitions looks low. Normalized RU consumption accounts for this distribution, giving you a true picture of whether your throughput is evenly spread or bottlenecked.
Callout: Normalized vs. Raw RU Consumption Raw RU consumption provides the absolute number of RUs consumed in a given second. While useful for billing, it is deceptive when monitoring performance. Normalized RU consumption is the "health gauge" of your database because it identifies whether your provisioned capacity is being utilized effectively or if your data partitioning strategy is causing "hot partitions."
Setting Up Monitoring in the Azure Portal
The Azure Portal provides a built-in "Insights" tab that is the primary interface for monitoring RU consumption. This tool is pre-configured to show you the normalized RU usage across your entire account, database, or specific containers.
Step-by-Step: Accessing the Metrics Explorer
- Navigate to your Azure Cosmos DB account in the Azure Portal.
- In the left-hand navigation pane, locate the Monitoring section.
- Click on Insights.
- Within the Insights blade, select the Throughput tab.
- You will see a series of charts. Look specifically for the chart labeled Normalized RU Consumption (%).
By default, this chart displays the maximum normalized RU consumption across all physical partitions over a specific time window. If you see the line hitting 100%, it means at least one of your physical partitions was throttled during that time interval.
Configuring Alerts
Monitoring is useless if you are not alerted when things go wrong. You should set up alert rules that trigger when your normalized RU consumption stays above a certain threshold for a sustained period.
- From the Insights or Metrics blade, click on New alert rule.
- Set the condition to trigger when
Normalized RU Consumptionis greater than 80% (this gives you a buffer to react before throttling occurs). - Configure the aggregation to be an "Average" over a 5-minute window to avoid being paged for micro-bursts that the server handles automatically.
- Assign an Action Group (e.g., email or SMS notification) to notify your engineering team.
Tip: Use 80% as your threshold. Setting an alert at 100% is reactive—you are already experiencing downtime. Setting an alert at 80% allows you to proactively scale your throughput or investigate inefficient queries before your users notice an issue.
Investigating Hot Partitions
A common mistake is assuming that simply increasing RU/s will solve all performance issues. If you have a "hot partition," increasing total throughput will not help because the bottleneck is not the total capacity, but the distribution of requests to a single physical partition.
Identifying the Culprit
If your normalized RU consumption is hitting 100% but your total RU usage is only a fraction of your provisioned capacity, you have a partitioning issue. You can use the Metrics blade to break down consumption by Partition Key Range ID.
- Go to Metrics.
- Select the Normalized RU Consumption metric.
- Click Apply splitting.
- Select PartitionKeyRangeId as the dimension.
This will show you a multi-line chart where each line represents a physical partition. If one line is at 100% while the others are at 10%, you have identified the hot partition.
How to Fix Hot Partitions
- Review your Partition Key: Does your key have high cardinality? If you used "Country" as a partition key, and 90% of your users are in the United States, that partition will always be hotter than the others.
- Synthetic Keys: If you cannot find a single property with high cardinality, combine two properties (e.g.,
UserId+Date) to create a unique, distributed key. - Avoid Monotonic Keys: Do not use timestamps or sequential IDs as your partition key if your application performs frequent writes. This causes all new data to be written to the "latest" partition, creating a bottleneck.
Code-Level Monitoring: Capturing RU Charges
While portal metrics are excellent for high-level health, developers often need to track RU consumption at the operation level within their code. This is essential for identifying which specific queries or write operations are "expensive."
Capturing RU in .NET (SDK v3)
When using the Azure Cosmos DB .NET SDK, every response object contains a RequestCharge property. You should log this value to your application performance monitoring (APM) tool (like Application Insights) whenever an operation exceeds a specific threshold.
// Example of capturing RU charge in .NET SDK v3
ItemResponse<MyDocument> response = await container.ReadItemAsync<MyDocument>("id123", new PartitionKey("partitionValue"));
double ruCharge = response.RequestCharge;
if (ruCharge > 10.0)
{
// Log this to your monitoring system
logger.LogWarning("Expensive operation detected: {ruCharge} RUs consumed", ruCharge);
}
By logging these charges, you can perform analytics on your operations. For example, you might discover that a specific search endpoint is consistently consuming 50 RUs per request, whereas it should only be consuming 5. This allows you to optimize the query before it ever impacts your normalized RU consumption metrics.
Best Practices for Maintaining Healthy RU Levels
Maintaining a healthy Cosmos DB environment is an ongoing process of optimization and monitoring. Below are the industry-standard practices for keeping your RU consumption within acceptable limits.
1. Optimize Queries
The most common cause of high RU consumption is inefficient querying. Avoid SELECT * whenever possible. Instead, select only the specific fields you need. Use filters that utilize your partition key to ensure that queries are "scoped" rather than "cross-partition."
2. Indexing Policy Management
Every property in your document is indexed by default. While this makes querying easy, it consumes RUs on every write operation. If you have a large document with fields that you never query, exclude those fields from the indexing policy to reduce write costs.
3. Use Server-Side Programming Sparingly
Stored procedures, triggers, and user-defined functions (UDFs) execute inside the database engine. While they are powerful, they can be RU-intensive. If you can perform the same logic in your application code, it is often better to do so, as you can scale your application tier more cheaply than your database tier.
4. Leverage Autoscale Throughput
If your workload is unpredictable, do not rely on manual RU provisioning. Use Autoscale provisioned throughput. This allows Cosmos DB to automatically scale your RU/s up and down based on traffic, ensuring you always have the capacity you need without paying for unused resources during idle times.
| Feature | Manual Throughput | Autoscale Throughput |
|---|---|---|
| Scaling | Fixed at a set value | Automatically scales 10% - 100% |
| Best For | Stable, predictable traffic | Spiky, unpredictable traffic |
| Cost | Lower if utilization is high | Higher base cost, but more efficient |
| Management | Requires manual adjustments | Fully automated |
Warning: Autoscale does not fix bad design. While autoscale is convenient, it can mask underlying performance issues. If your application is poorly indexed or has hot partitions, autoscale will simply keep increasing your costs to compensate for bad code. Always optimize your queries and data model first.
Common Pitfalls and How to Avoid Them
Even experienced engineers fall into common traps when managing Cosmos DB. Below are the most frequent mistakes and how to steer clear of them.
Mistake 1: Ignoring the "429" Error
The most common mistake is failing to handle 429: Too Many Requests errors in application code. When Cosmos DB throttles a request, it returns a Retry-After header. Your SDK handles this automatically, but if you are using a custom wrapper or a different language, you must implement an exponential backoff retry strategy. Ignoring this will lead to application crashes during peak times.
Mistake 2: The "Big Query" Trap
Developers often write a single, massive query to fetch all required data for a dashboard. As the data grows, the RU cost of that query grows linearly. Break these down into smaller, targeted queries or fetch data in pages using continuation tokens.
Mistake 3: Cross-Partition Queries
A cross-partition query must be sent to every physical partition in the container. If you have 50 partitions, a single query incurs the cost of 50 lookups. Always design your queries to include the partition key in the WHERE clause so the query engine only hits the relevant partition.
Mistake 4: Over-Indexing
Adding every single field to your index policy makes writes extremely expensive. Only index the fields that are actually used in WHERE clauses, ORDER BY clauses, or as filters.
Advanced Troubleshooting: Using Diagnostic Logs
When standard metrics are not enough, you need to dive into the Diagnostic Logs. These logs provide granular detail about every request, including the status code, the RU charge, and the latency.
Enabling Diagnostic Logs
- In your Cosmos DB account, go to Diagnostic settings.
- Click Add diagnostic setting.
- Select the logs you want (e.g.,
DataPlaneRequests,QueryRuntimeStatistics). - Send these logs to a Log Analytics Workspace.
Once in Log Analytics, you can write Kusto Query Language (KQL) queries to identify the exact queries causing high RU consumption. For example:
// KQL query to find the most expensive queries
AzureDiagnostics
| where Category == "QueryRuntimeStatistics"
| summarize AvgRU = avg(requestCharge_s) by queryText_s
| top 10 by AvgRU desc
This level of visibility is invaluable. It allows you to see exactly which SQL query is responsible for your RU spikes, helping you decide whether to add a composite index or rewrite the query entirely.
The Role of SDKs in RU Efficiency
The Azure Cosmos DB SDKs are designed to be "smart." They include built-in logic for connection pooling, retries, and request routing. When monitoring RU consumption, ensure you are using the latest version of the SDK for your language. Older versions may have less efficient connection handling, which can indirectly lead to higher RU overhead due to connection churn or sub-optimal request routing.
Furthermore, the SDKs allow you to set the ConsistencyLevel. While "Strong" consistency provides the highest data integrity, it is also the most RU-intensive because it requires synchronization across replicas. If your application can tolerate "Session" or "Eventual" consistency, you can significantly reduce your RU consumption for read operations. Always evaluate if your business requirements truly demand "Strong" consistency before defaulting to it.
Summary of Best Practices
- Monitor Early: Do not wait for production issues. Monitor normalized RU consumption in your staging/QA environments under simulated load.
- Alert Proactively: Set alerts at 80% to give your team time to investigate before the system throttles.
- Partition Wisely: Spend time choosing the right partition key. It is the most important decision you will make in your Cosmos DB design.
- Optimize the Index: Regularly review your indexing policy. Remove unused indexes and use composite indexes for complex multi-field queries.
- Log Expensive Queries: Use the
RequestChargeproperty in your application logs to track the cost of every operation. - Use Autoscale: For workloads with fluctuating traffic, autoscale is a cost-effective way to handle spikes without constant manual intervention.
- Review Consistency: Evaluate your consistency requirements. Lowering consistency levels can yield significant performance gains and cost savings.
Final Key Takeaways
- Normalized RU Consumption is the primary indicator of health: It effectively balances provisioned throughput against actual utilization, accounting for partition distribution.
- Throttling is avoidable: By monitoring and alerting at the 80% threshold, you can prevent HTTP 429 errors from affecting your users.
- Partitioning is the root of most problems: If your normalized RU consumption is high while total usage is low, you likely have a hot partition issue that needs to be resolved by refining your partition key.
- Granular visibility is key: Use SDK logging and Diagnostic Logs to identify specific queries that are consuming excessive resources.
- Optimization is a loop: Monitoring, identifying expensive operations, optimizing the data model or query, and re-monitoring should be a continuous cycle in your development process.
- Understand the "Why": RU consumption is driven by data size, index overhead, consistency levels, and query complexity. Addressing these factors at the source is more effective than simply purchasing more throughput.
- Cost Management: Efficient RU consumption directly translates to lower operational costs, making it a critical aspect of cloud financial management (FinOps).
By internalizing these concepts and following these practices, you will move from being a user of Azure Cosmos DB to a proficient manager of distributed database performance. You will be able to build applications that are not only performant and reliable but also cost-efficient, ensuring that your cloud infrastructure supports your business goals rather than hindering them.
Reach the last section to complete this lesson and earn points — you're on section 1 of 11.
- Introduction to Cosmos DB Data Modeling
- Introduction to Cosmos DB Data Modeling Quiz5q
- Multiple Entity Types in Same Container
- Multiple Entity Types in Same Container Quiz5q
- Storing Related Entities in Same Document
- Storing Related Entities in Same Document Quiz5q
- Denormalizing Data Across Documents
- Denormalizing Data Across Documents Quiz5q
- Referencing Between Documents
- Referencing Between Documents Quiz5q
- Partition Keys and Document IDs
- Partition Keys and Document IDs Quiz5q
- Time to Live (TTL) Configuration
- Time to Live (TTL) Configuration Quiz5q
- Document Versioning Strategies
- Document Versioning Strategies Quiz5q
- Schema Versioning Patterns
- Schema Versioning Patterns Quiz5q
- Choosing Partition Strategies
- Choosing Partition Strategies Quiz5q
- Partition Key Selection Best Practices
- Partition Key Selection Best Practices Quiz5q
- Transactions and Partition Keys
- Transactions and Partition Keys Quiz5q
- Cross-Partition Query Costs
- Cross-Partition Query Costs Quiz5q
- Data Distribution Analysis
- Data Distribution Analysis Quiz5q
- Throughput Distribution Planning
- Throughput Distribution Planning Quiz5q
- Synthetic Partition Keys
- Synthetic Partition Keys Quiz5q
- Hierarchical Partition Keys
- Hierarchical Partition Keys Quiz5q
- Throughput and Storage Requirements
- Throughput and Storage Requirements Quiz5q
- Serverless vs Provisioned Throughput
- Serverless vs Provisioned Throughput Quiz5q
- Database-Level Provisioned Throughput
- Database-Level Provisioned Throughput Quiz5q
- Granular Scale Units
- Granular Scale Units Quiz5q
- Global Distribution Costs
- Global Distribution Costs Quiz5q
- Configuring Throughput in Portal
- Configuring Throughput in Portal Quiz5q
- Gateway vs Direct Connectivity Mode
- Gateway vs Direct Connectivity Mode Quiz5q
- Creating Database Connections
- Creating Database Connections Quiz5q
- Azure Cosmos DB Emulator
- Azure Cosmos DB Emulator Quiz5q
- Connection Error Handling
- Connection Error Handling Quiz5q
- Singleton Pattern for Clients
- Singleton Pattern for Clients Quiz5q
- Global Distribution Regions
- Global Distribution Regions Quiz5q
- Threading and Parallelism
- Threading and Parallelism Quiz5q
- Arrays and Nested Objects Queries
- Arrays and Nested Objects Queries Quiz5q
- Correlated Subqueries
- Correlated Subqueries Quiz5q
- Array and Type-Checking Functions
- Array and Type-Checking Functions Quiz5q
- Mathematical and String Functions
- Mathematical and String Functions Quiz5q
- Date Functions in Queries
- Date Functions in Queries Quiz5q
- Point Operations vs Query Operations
- Point Operations vs Query Operations Quiz5q
- CRUD Point Operations
- CRUD Point Operations Quiz5q
- Patch Operations for Updates
- Patch Operations for Updates Quiz5q
- Transactional Batch Operations
- Transactional Batch Operations Quiz5q
- Bulk Operations with SDK
- Bulk Operations with SDK Quiz5q
- Optimistic Concurrency with ETags
- Optimistic Concurrency with ETags Quiz5q
- Query Pagination and Continuation
- Query Pagination and Continuation Quiz5q
- Cosmos DB Mirroring for Fabric
- Cosmos DB Mirroring for Fabric Quiz5q
- Mirroring vs Spark Connector
- Mirroring vs Spark Connector Quiz5q
- Enabling Analytical Store
- Enabling Analytical Store Quiz5q
- Synapse Spark and SQL Queries
- Synapse Spark and SQL Queries Quiz5q
- Change Data Capture in Analytical Store
- Change Data Capture in Analytical Store Quiz5q
- Azure Functions and Event Hubs Integration
- Azure Functions and Event Hubs Integration Quiz5q
- Denormalization with Change Feed
- Denormalization with Change Feed Quiz5q
- Referential Integrity with Change Feed
- Referential Integrity with Change Feed Quiz5q
- Azure AI Search Integration
- Azure AI Search Integration Quiz5q
- Azure Functions Change Feed Trigger
- Azure Functions Change Feed Trigger Quiz5q
- Consuming Change Feed with SDK
- Consuming Change Feed with SDK Quiz5q
- Change Feed Estimator
- Change Feed Estimator Quiz5q
- Denormalization via Change Feed
- Denormalization via Change Feed Quiz5q
- Aggregation Persistence with Change Feed
- Aggregation Persistence with Change Feed Quiz5q
- Read-Heavy vs Write-Heavy Indexing
- Read-Heavy vs Write-Heavy Indexing Quiz5q
- Index Type Selection
- Index Type Selection Quiz5q
- Custom Indexing Policies
- Custom Indexing Policies Quiz5q
- Composite Index Implementation
- Composite Index Implementation Quiz5q
- Index Performance Optimization
- Index Performance Optimization Quiz5q
- Response Status Codes and Metrics
- Response Status Codes and Metrics Quiz5q
- Normalized RU Consumption Monitoring
- Normalized RU Consumption Monitoring Quiz5q
- Server-Side Latency Metrics
- Server-Side Latency Metrics Quiz5q
- Data Replication Monitoring
- Data Replication Monitoring Quiz5q
- Azure Monitor Alerts Configuration
- Azure Monitor Alerts Configuration Quiz5q
- Resource Logs Implementation
- Resource Logs Implementation Quiz5q
- Partition Throughput Monitoring
- Partition Throughput Monitoring Quiz5q
- Encryption Key Management
- Encryption Key Management Quiz5q
- Network-Level Access Control
- Network-Level Access Control Quiz5q
- Data Encryption Configuration
- Data Encryption Configuration Quiz5q
- Azure RBAC for Control Plane
- Azure RBAC for Control Plane Quiz5q
- Microsoft Entra ID for Data Plane
- Microsoft Entra ID for Data Plane Quiz5q
- CORS Settings Configuration
- CORS Settings Configuration Quiz5q
- Customer-Managed Keys
- Customer-Managed Keys Quiz5q
- Always Encrypted Implementation
- Always Encrypted Implementation Quiz5q
- Data Movement Strategy Selection
- Data Movement Strategy Selection Quiz5q
- SDK Bulk Operations for Data Movement
- SDK Bulk Operations for Data Movement Quiz5q
- Azure Data Factory Pipelines
- Azure Data Factory Pipelines Quiz5q
- Kafka Connector Integration
- Kafka Connector Integration Quiz5q
- Azure Stream Analytics Integration
- Azure Stream Analytics Integration Quiz5q
- Cosmos DB Spark Connector
- Cosmos DB Spark Connector Quiz5q
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles the points you earn on every lesson and quiz so you progress twice as fast, unlocks half of every practice exam — plus full case studies — with the Learn & Exam study modes, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× points per lesson & quiz
- ✓ 50% of every exam unlocked
- ✓ Learn & Exam modes
- ✓ Distraction-free lessons