Normalized RU Consumption Monitoring

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 11 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — 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.


Not read yet

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."


Not read yet

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

  1. Navigate to your Azure Cosmos DB account in the Azure Portal.
  2. In the left-hand navigation pane, locate the Monitoring section.
  3. Click on Insights.
  4. Within the Insights blade, select the Throughput tab.
  5. 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.

  1. From the Insights or Metrics blade, click on New alert rule.
  2. Set the condition to trigger when Normalized RU Consumption is greater than 80% (this gives you a buffer to react before throttling occurs).
  3. Configure the aggregation to be an "Average" over a 5-minute window to avoid being paged for micro-bursts that the server handles automatically.
  4. 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.


Not read yet

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.

  1. Go to Metrics.
  2. Select the Normalized RU Consumption metric.
  3. Click Apply splitting.
  4. 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.

Not read yet

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.


Not read yet

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.


Not read yet

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.


Not read yet

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

  1. In your Cosmos DB account, go to Diagnostic settings.
  2. Click Add diagnostic setting.
  3. Select the logs you want (e.g., DataPlaneRequests, QueryRuntimeStatistics).
  4. 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.


Not read yet

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.


Not read yet

Summary of Best Practices

  1. Monitor Early: Do not wait for production issues. Monitor normalized RU consumption in your staging/QA environments under simulated load.
  2. Alert Proactively: Set alerts at 80% to give your team time to investigate before the system throttles.
  3. Partition Wisely: Spend time choosing the right partition key. It is the most important decision you will make in your Cosmos DB design.
  4. Optimize the Index: Regularly review your indexing policy. Remove unused indexes and use composite indexes for complex multi-field queries.
  5. Log Expensive Queries: Use the RequestCharge property in your application logs to track the cost of every operation.
  6. Use Autoscale: For workloads with fluctuating traffic, autoscale is a cost-effective way to handle spikes without constant manual intervention.
  7. Review Consistency: Evaluate your consistency requirements. Lowering consistency levels can yield significant performance gains and cost savings.

Not read yet

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.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.