Question

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

You are designing an Azure Cosmos DB container to store telemetry data from millions of IoT devices. The workload has a high-write throughput profile (10,00010,000 writes per second) and reads are scoped to individual devices. You need to ensure that transactions are restricted to a single device's data, and that storage and Request Units (RUs) are distributed evenly to avoid hot partitions. Which property should you select as the partition key?

  1. A
    status
  2. B
    factoryLocation
  3. deviceIdAnswer
  4. D
    deviceType

Answer

The deviceId property should be selected as the partition key.
The correct partition key is the device identifier. Selecting a partition key with high cardinality, such as the device identifier, ensures that storage and request throughput are distributed evenly across logical and physical partitions. Since transactions are restricted to a single device's data, grouping by the device identifier satisfies the transactional scope.

Step-by-Step Solution

1
Analyze the workload requirements, throughput profile, and transaction boundaries.
The workload requires 10,00010,000 writes per second, reads scoped to individual devices, and transactions restricted to a single device's data.
This identifies the key criteria: high cardinality for write distribution and grouping by device for reads and transactions.
2
Evaluate the cardinality of the candidate partition keys.
The deviceId property has millions of unique values (high cardinality), whereas status, factoryLocation, and deviceType have low cardinality.
Azure Cosmos DB partitions work best when the partition key has a wide range of values to distribute storage and throughput evenly.
3
Select the key that satisfies both transaction boundaries and even distribution.
The deviceId property keeps a single device's data within the same logical partition for transactions while distributing the workload evenly.
This avoids hot partitions and meets the query and transactional requirements of the application.

Key Concept

Partition key selection in Azure Cosmos DB requires choosing a property with high cardinality to distribute throughput and storage evenly, while aligning with the query patterns and transactional boundaries of the application.
Rate this question