A logistics company is designing an Azure Cosmos DB container to store delivery tracking records. The system receives a high volume of writes representing tracking status updates. Each tracking record contains a `shipmentId`, a `destinationCountry`, and a `statusDate` (formatted as YYYY-MM-DD). The system must support transactional batch writes (using `TransactionalBatch`) for all status updates of a single shipment on a specific date. The destination country has low cardinality, with 10 countries representing 95% of all shipments. You must prevent hot partitions during peak shipping seasons while satisfying the transactional boundary. Which two actions should you perform to configure the partitioning strategy?
- Create a synthetic partition key by concatenating shipmentId and statusDate in each item.Answer
- Set the container's partition key path to the custom synthetic property.Answer
- CConfigure destinationCountry as the partition key to optimize queries that filter by country.
- DConfigure Session consistency to guarantee transactional ACID compliance for batch updates across different shipment partitions.
Answer
Create a synthetic partition key by concatenating shipmentId and statusDate in each item, and configure the container's partition key path to point to the custom synthetic property.
To support transactional batches for updates of a single shipment on a specific date, all involved items must share the same partition key. Concatenating shipmentId and statusDate to create a synthetic partition key satisfies this constraint. Selecting this synthetic property as the container's partition key distributes writes evenly due to its high cardinality, preventing hot partition issues that would arise from using destinationCountry.
Step-by-Step Solution
Key Concept
Azure Cosmos DB partitioning strategy, including synthetic partition keys and transactional boundaries.
Estimated Time:2m 0s