Azure Cosmos DB – Consistency, Partitioning and SDK · AZ-204: Developing Solutions for Microsoft Azure Develop for Azure Storage
A Cosmos DB container stores telemetry for many tenants. Its current partition key is /tenantId, but one tenant produces most of the telemetry, causi…
Practice question from Azure Cosmos DB – Consistency, Partitioning and SDK (AZ-204: Developing Solutions for Microsoft Azure Develop for Azure Storage), with the correct answer and a step-by-step solution.
medium · MCQ · Q-40BF91
A Cosmos DB container stores telemetry for many tenants. Its current partition key is /tenantId, but one tenant produces most of the telemetry, causing a hot logical partition and uneven request distribution. Queries commonly filter by tenant and time, and transactions do not need to span multiple devices. Which redesign is most appropriate?
- A.Keep /tenantId because all queries include the tenant identifier.
- B.Use /timestamp so recent telemetry is always placed together.
- C.Use a high-cardinality synthetic key such as tenantId + ':' + deviceId.Correct answer
- D.Use the tenant's display name and manually move items between partitions.
Solution
A high-cardinality synthetic key such as tenantId + ':' + deviceId distributes writes for a large tenant across multiple logical partitions while retaining tenant information for filtering. A partition key is selected when the container is created; changing it generally requires creating a new container and migrating the data.
More from Azure Cosmos DB – Consistency, Partitioning and SDK
- An application uses Azure Cosmos DB to update a user's profile and then immediately read the profile during the same user session. The read…
- A .NET application uses the Azure Cosmos DB SDK v3. The container's partition key path is /customerId, and the application must retrieve th…
- A globally distributed Azure Cosmos DB account must allow reads from any region, but each read may lag behind the latest write by no more t…
- An Azure Cosmos DB container stores orders for 10,000 retail stores. Most queries retrieve orders for a specific store, and writes are dist…
Practise more Develop for Azure Storage
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed