Optimize an Azure Cosmos DB solution
Drill 20 practice questions focused entirely on Optimize an Azure Cosmos DB solution for the Microsoft DP-420 exam. Tap an answer for instant feedback and a full explanation — no sign-up, always free.
Your team runs an Azure Functions app with a Cosmos DB trigger that processes the change feed from an 'Orders' container. During a recent sales event, downstream systems reported that order-processing events were arriving several minutes late. You need to programmatically measure how far behind the change feed processor is falling so you can trigger alerts and scale the function before the backlog grows. Which approach should you implement?
You are building an audit-and-replication pipeline on a Cosmos DB for NoSQL container. The downstream system must observe every intermediate change to each item — including updates that happened between reads — and must also be notified when items are deleted (so it can remove them from a search index). You will consume the change feed using the .NET SDK with the change feed processor. Which change feed configuration meets these requirements?
You built a change feed consumer using the .NET SDK's change feed processor to project order events into a downstream reporting container. To maximize throughput, you configured the processor to checkpoint only after every 500 processed changes rather than after each batch. During a load test, the host process crashed unexpectedly. When the processor restarts, what behavior should you expect, and what is the primary trade-off of your checkpoint configuration?
You are building a .NET consumer using the change feed processor from the Cosmos DB SDK to process an order-events container. During peak hours, a single processor host cannot keep up, and the change feed estimator reports growing lag. Your monitored container has 6 physical partitions. You deploy 3 additional identical instances of the same application (4 total), all configured with the same processor name, the same lease container, and the same instance-specific 'instanceName'... except two instances were accidentally deployed with an identical 'instanceName'. What is the effect on lease (partition) distribution and processing?
An e-commerce team stores orders in a Cosmos DB container partitioned by /customerId. A separate reporting service needs a continuously updated materialized view aggregating daily sales totals per product into a second container partitioned by /productId. The team wants a low-latency, resilient mechanism that reacts to each new or updated order without polling or scheduled full scans. Which approach should they implement?
A logistics company stores shipment documents in a Cosmos DB for NoSQL container. A dashboard runs a frequent query that filters on `WHERE c.warehouseId = @id` and returns results ordered by two fields: `ORDER BY c.status ASC, c.createdDate DESC`. The query currently fails at runtime with an error stating that an ORDER BY query requires a corresponding composite index. Which change to the indexing policy will allow this query to execute?
A retail analytics team runs a frequent query against a Cosmos DB container that returns the newest, highest-value orders: SELECT * FROM c WHERE c.status = 'shipped' ORDER BY c.orderDate DESC, c.totalAmount DESC. The query currently fails at runtime with an error indicating the ORDER BY clause cannot be served. The container uses the default indexing policy. What is the most appropriate change to make this multi-property ORDER BY query succeed with minimal RU overhead?
An e-commerce reporting service queries a Cosmos DB container with millions of order documents. The query returns thousands of matching results, but the frontend displays only 50 items per page. Currently the code executes the query, materializes the entire result set into memory, and slices out 50 items per request — consuming large amounts of RUs and memory on every page load. You must minimize RU cost and memory usage while preserving the ability to fetch subsequent pages. What should you do?
A high-throughput orders container ingests thousands of writes per second. Documents contain dozens of properties, but analysts only ever filter on 'status' and 'customerId', and sort on 'orderDate'. The team notices write RU charges are very high due to the default indexing policy indexing every path. They want to minimize write RU cost while still supporting the known query patterns efficiently. Which indexing policy change best achieves this?
A data engineering team must perform a one-time bulk migration of 500 million documents into a new Cosmos DB container. During the load, no queries will run against the container; queries only begin after the migration completes and is validated. The team wants to minimize the RU cost and maximize write throughput during the bulk load, while still supporting rich queries afterward. What is the most effective indexing approach?
A high-throughput order-ingestion container writes 5,000 documents per second. Each document has 60 properties, but analysts only ever filter and sort on 4 of them: orderStatus, customerId, orderDate, and region. The team notices write RU charges are very high and wants to reduce them without breaking the analyst queries. What indexing policy change should they apply?
A logistics company stores shipment tracking documents in an Azure Cosmos DB for NoSQL container. Each document contains a large nested 'rawSensorPayload' object with dozens of properties that are never used in query filters, ORDER BY, or JOIN clauses — they are only returned when a document is read by id. The write workload is heavy, and the team notices high RU charges on every insert and update. Queries only ever filter on 'shipmentId', 'status', and 'region'. What is the most effective change to reduce write RU consumption while preserving query performance?
A retail analytics team enabled the integrated cache via a dedicated gateway to reduce RU charges on a set of frequently repeated queries. Most queries now return RU charge of 0, but one high-volume query keeps showing full RU cost on every execution even though it is identical each time. Investigation shows the SDK client for that query sets the request consistency level to Strong, while the account default is Session. What is the most likely cause of the cache never being used for that query?
A retail analytics dashboard issues the same set of point reads and queries thousands of times per minute against an Azure Cosmos DB for NoSQL container. The data changes only a few times per hour, but the team is alarmed by the RU consumption and cost from these repetitive reads. They want to dramatically reduce RU charges for the repeated reads without changing the queries themselves. Which approach best meets this requirement?
A retail application uses an Azure Cosmos DB dedicated gateway with the integrated cache enabled to serve a product catalog. The catalog is updated a few times per hour, but the team is willing to serve slightly stale data to maximize cache hits and reduce RU consumption on repeated reads. Currently, every read request is configured with the default MaxIntegratedCacheStaleness of 5 minutes, but the team wants cached entries to remain valid for up to 30 minutes to further cut costs. Which action correctly achieves this while ensuring the cache is actually used?
Your team enabled the Azure Cosmos DB integrated cache by provisioning a dedicated gateway and routing the .NET SDK client through gateway mode with the dedicated gateway endpoint. A frequently repeated query still shows full RU charges on most executions rather than the expected near-zero cost. Investigation reveals the application sets the request consistency level to Strong on each query. What is the most likely reason the integrated cache is not serving these queries?
You are tuning a frequently executed query in a .NET application that reads from an Azure Cosmos DB for NoSQL container. Before making indexing changes, you want to accurately capture the exact RU charge consumed by each individual query execution to establish a baseline. What is the most reliable way to obtain the actual RU charge for a specific query execution?
A developer notices that a frequently executed query filtering on 'c.status = "active"' has a high RU charge. Using the Query Metrics from the SDK response, they observe that the 'Index Hit Document Count' is much lower than the 'Retrieved Document Count', and 'Index Lookup Time' is minimal while 'Document Load Time' dominates. What is the most likely cause and appropriate remediation?
A developer notices that a frequently executed query in a customer-profile container returns entire documents, each roughly 50 KB in size, even though the application UI only displays the customer's name, email, and loyalty tier. The container has around 2 million documents, and this query runs thousands of times per minute, driving up RU consumption. Which change will most directly reduce the RU cost of this query without altering the indexing policy?
A developer runs the following query frequently against a container that uses the default indexing policy: SELECT * FROM c WHERE c.temperature > 30 AND c.status = 'active'. The container is read-heavy with modest write volume. Query metrics show a low index hit ratio and higher-than-expected RU charges because the query performs a large scan after the index seek. Which single change will most effectively reduce the RU charge of this specific query?
More DP-420 practice
Keep going with the other Microsoft Azure Cosmos DB Developer Specialty (DP-420) domains, or take a full timed mock exam.
← Back to DP-420 overview