Cosmos DB can be a good candidate for a key-value store. Cosmos DB is a multimodal database in Azure that supports schema-less storage. By default, Cosmos DB containers tend to index all the fields of a document uploaded. We can limit the index properties only to id and partitionkey to make the container a pure key-value store. Prohibiting other fields to be indexed increases performance and reduces RU to query point records. (Cosmos DB cost is measured in RU.) For key object storage, RU tends to be less, but it still depends on the payload size. Performance tests conducted on 100 partitions and 100K records gave a P95 between 25-30ms for read and write.

Let’s dive in and implement Cosmos DB as a pure key-value store in C#.

Leave a Reply

Your email address will not be published. Required fields are marked *