I have inserted into a CosmosDB collection 300k documents using many different values for the partition key attribute defined for the collection. When I try to read from the ChangeFeed (using both Azure Functions and ChangeFeedProcessor sample) I get always a single thread cosuming events with a PartitionKeyRange value 0.
I don't understand why I get only changes from a sinlge PartitionKeyRange even if I have so many different values in the defined partition key of the collection.
Any suggestion?
UPDATE: I have run the PartitionStats project included in the samples for Cosmos DB and you can see below the output. It seems that I am getting only one "PartitionKeyRange" for all my "Logical Partitions".
PartitionKeyRanges are not equivalent to partition keys. This naming is a little confusion and we're working on changing it in the next versions of our SDKs. Think of partition keys as the logical grouping of data that you can control, and partition keys is the physical representation of that grouping that the backend controls. It consists of (usually) many logical partition keys.
The number of PartitionKeyRanges cannot be controlled by you, the end user, but is instead managed by the backend for you. It is determined by a combination of reserved throughput, amount of storage used, and utilization patterns. It is recommended not to design around having more PartitionKeyRanges as that can change at any time, but instead focusing on processing the feed as fast as possible. You may need to push any CPU intensive work into, for instance, a queue where the work can be further parallelized without delaying the processing of the stream.