You are reviewing an Azure Cosmos DB for NoSQL design for a fleet-monitoring solution before it goes to production.
- 50,000 devices send readings continuously throughout the day.
- Each reading is stored as a separate item of about 1 KB in a
telemetrycontainer. - A reading is never updated after it is inserted.
- The partition key is
/readingDate, a string inyyyy-MM-ddformat. - Data is retained for three years, so the container will hold about 1,100 distinct
readingDatevalues. - The most frequent query filters on readingDate to return the readings for one day.
Which partitioning anti-pattern should you report for the telemetry container?
A date-based key looks fine when you count all values over the retention period, but at any moment almost every new write carries the current date. That sends the live write traffic to one logical partition, which is the anti-pattern of a key that concentrates current writes. The scenario rules out the other anti-patterns: the key has many values, it never changes, items are small and separate, and the main query filters on the key. A synthetic key with a suffix is one way to spread those writes.
- Correct: A key that concentrates current writes. Because devices write continuously and every new reading carries today's date, nearly all current inserts land in a single logical partition, even though the total number of date values looks healthy.
- Not correct: High cardinality with no query alignment. That anti-pattern describes a key that no query filters on, causing fan-out. The dominant query filters on the partition key, so it is routed to one partition.
- Not correct: A mutable partition key value. The mutable-key anti-pattern applies when the business changes the partition key property, forcing a delete and insert. Readings are never updated, so the key value never changes.
- Not correct: A low-cardinality partition key. Low-cardinality keys have few possible values, such as a fixed set of statuses. Here retained data spans about 1,100 date values; the problem is that current writes all share one date despite that historical variety.
- Not correct: Unbounded growth inside an item. Unbounded growth refers to an array inside one item that grows with activity. Each reading here is its own small item, so no item grows over time.