A public transit agency is designing an Azure Cosmos DB for NoSQL database to store real-time telemetry from a fleet of 5,000 buses. The system ingests 10 million location updates daily. The database must optimize for high-throughput write ingestions while ensuring fleet managers can perform ACID-compliant transactional batch updates to modify the status of a specific bus on a given calendar day. Using the bus ID alone as the partition key would optimize reads for individual buses but will eventually exceed the 20 GB logical partition storage limit due to historical accumulation. Which two of the following design decisions should you make to satisfy these requirements?
- Configure a synthetic partition key by concatenating the bus ID and the date portion of the timestamp (for example, busID_YYYYMMDD) to define the partition key for the container.Cevap
- Execute the status updates using the TransactionalBatch class in the SDK, ensuring all operations in the batch target the same synthetic partition key value.Cevap
- CUse the bus ID as the container partition key and rely on Cosmos DB to automatically split the logical partition when the historical data size exceeds 20 GB.
- DSet the database consistency level to Session to guarantee ACID transactional boundaries across multiple independent client sessions without sharing session tokens.
Cevap
To satisfy these requirements, you must configure a synthetic partition key by concatenating the bus ID and the date portion of the timestamp (for example, busID_YYYYMMDD) to define the partition key, and execute the status updates using the TransactionalBatch class in the SDK, ensuring all operations in the batch target the same synthetic partition key value.
Concatenating the bus ID with the date creates a synthetic partition key that guarantees a high cardinality distribution while keeping the size of each logical partition well under the 20 GB storage limit, as data is divided into daily chunks. Since all status documents for a specific bus on a given day share this key, they can be updated atomically using the TransactionalBatch class in the SDK.
Adım Adım Çözüm
Anahtar Kavram
Synthetic partition keys and TransactionalBatch boundaries in Azure Cosmos DB