Question

Difficulty: EasyConfigure Partition Keys and Partitioning Strategies in Azure Cosmos DB

An organization is developing a delivery driver tracking system that stores location logs in an Azure Cosmos DB container. The system processes thousands of status updates per minute from active drivers. Write operations are distributed evenly across all drivers, and the most common queries retrieve location history for a specific driver. The container must distribute storage and Request Units (RUs) uniformly without causing hot partitions. Which property should be configured as the partition key?

  1. driverIdAnswer
  2. B
    city
  3. C
    status
  4. D
    logId

Answer

driverId
Selecting driverId is correct because it has high cardinality and matches the query filter. This ensures that driver-specific queries are routed directly to a single partition (single-partition queries) while writes are evenly distributed across all active drivers.

Step-by-Step Solution

1
Analyze the query and write patterns for the Cosmos DB workload.
Writes are distributed across drivers, and read queries frequently search by a specific driver.
Choosing a key that aligns with search filters minimizes cross-partition queries.
2
Evaluate candidate properties for partition key cardinality.
driverId and logId have high cardinality, whereas city and status have lower cardinality.
High cardinality is necessary to prevent hot partitions by distributing data across many physical partitions.
3
Select the key that satisfies both cardinality and query routing.
driverId is the optimal choice because it is highly unique and matches the filter for the primary query pattern.
This avoids cross-partition queries while maintaining uniform resource distribution.

Key Concept

Selecting a partition key that matches query filters and has high cardinality to distribute throughput and storage.
Rate this question