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.
A sample of the data is shown in the exhibit.
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. Use timestamp as the partition key.
- B. Create a new synthetic key that contains deviceId and sensor1Value.
- C. Create a new synthetic key that contains deviceId and deviceManufacturer.
- D. Create a new synthetic key that contains deviceId and a random number. Correct
Explanation
Appending a random suffix to deviceId spreads each device's continuous writes across several logical partitions, which removes hot partitions, keeps partitions evenly sized and stops any one device from reaching the 20 GB logical partition limit. Timestamp concentrates all current writes on one value at a time, creating a hot partition. sensor1Value is a Boolean, so deviceId plus sensor1Value adds at most two values per device, and deviceManufacturer adds nothing because each device has only one manufacturer, so both still leave every device's writes in one or two partitions.