Question
You are designing an Azure Cosmos DB for NoSQL solution to store data from IoT devices. Writes from the devices will occur every second.
The following is a sample of the data.
```json
{
"id" : "03c1ca5a-db18-4231-908f-09a9bc7a7c3e",
"deviceManufacturer" : "Contoso, Ltd",
"deviceId" : "f460df85-799f-4d58-b051-67561b4993c6",
"timestamp" : "2021-09-19T13:47:45",
"sensor1Value" : true,
"sensor2Value" : "75",
"sensor3Value" : "4554",
"sensor4Value" : "454",
"sensor5Value" : "42128"
}
```
You need to select a partition key that meets the following requirements for writes:
- Minimizes the partition skew
- Avoids capacity limits
- Avoids hot partitions
What should you do?
- A. Create a new synthetic key that contains deviceId and timestamp Correct
- B. Use timestamp as the partition key
- C. Use deviceManufacturer as the partition key
- D. Use sensor1Value as the partition key
Explanation
A synthetic key combining deviceId and timestamp has very high cardinality and spreads writes evenly, so no logical partition grows toward the 20 GB limit or receives a disproportionate share of writes. Timestamp alone sends every write in the same second to the same partition, creating a hot partition. deviceManufacturer and the boolean sensor1Value have very few distinct values, which causes heavy skew and eventually hits the logical partition size limit.