1

I have created an azure function that uses CosmosDBTrigger to monitor changes. Azure Function Setup

I added 120,000 items to the container very quickly and watched my azure function scale to 20 servers but there CPU was barely being utilized (except for one) 20 Servers, not using CPU enough

I checked my lease container and there was only two items, one being the lease and one being the .info enter image description here

Here is the settings for the lease container enter image description here

My partition in my container I am listening to is "ClientOrderId" so every order is in its own partition (write heavy). Why isn't my lease container distributing the leases so my azure functions can run in parallel?

Thanks in advance.

Daniel Boyer
  • 371
  • 3
  • 18

1 Answers1

1

The number of leases is for the Physical Partitions, not Logical Partitions.

See: https://learn.microsoft.com/azure/cosmos-db/partition-data

Matias Quaranta
  • 13,907
  • 1
  • 22
  • 47
  • You're right, I only have one physical partition on my machine. If that's the case, is there no way for me to evenly split my new changes across the azure function processes? I check another lease container which I have and it has two leases, but only one physical partition, I don't think leases match physical partitions. – Daniel Boyer Oct 23 '20 at 20:58
  • You cannot parallelize Change Feed consumption at a different granularity level, the REST API contract currently defines that it's the Physical partition. There are always 1 lease document per physical partition plus 1 document with `.info` in the `id`. – Matias Quaranta Oct 23 '20 at 22:10
  • You can even see on the lease documents that there is a `PartitionId` property with the number of the partition assigned to that lease. – Matias Quaranta Oct 23 '20 at 22:11