A healthcare organization is designing a monitoring application that collects real-time telemetry from wearable patient devices and stores the data in an Azure Cosmos DB for NoSQL container. The application hosts active patient devices, each sending health metrics every , resulting in a high volume of continuous writes. The primary query pattern retrieves telemetry data for a specific patient for a single calendar day to populate a daily dashboard. Telemetry data for a single patient is expected to grow by approximately per year. Which partition key strategy should you implement to support the query requirements while preventing partition size limits and write hot spotting?
- Create a synthetic partition key by concatenating the patientId and date values (for example, patientId_YYYY-MM-DD).Answer
- BUse patientId as the partition key.
- CUse date as the partition key.
- DCreate a synthetic partition key by appending a random integer between 1 and 10 to patientId (for example, patientId_X).
Answer
Create a synthetic partition key by concatenating the patientId and date values (for example, patientId_YYYY-MM-DD).
Concatenating the patient identifier and the date creates a synthetic partition key with high cardinality that distributes writes evenly across partitions. Because each logical partition contains only one day of telemetry for a single patient, it easily fits within the 20 GB partition limit. This partition key also aligns with the primary read query pattern, allowing the system to serve the daily dashboard through an efficient point read or single-partition query.
Step-by-Step Solution
Key Concept
Selecting or constructing a partition key in Azure Cosmos DB to distribute storage and throughput workloads evenly while satisfying application query patterns.