问题
I have my Azure function with CosmosDB trigger, that listens to a collection using lease collection mechanism. This function is hosted on consumption plan.
I have noticed that under heavy load I tend to get updates to my function with a greater and greater delay. After reading documentation I did not find a way how to improve scaling of my setup. Is there a way to?
回答1:
Consumption Plan instances should grow based on how far behind your Function is lagging. If you are using Consumption Plan, if you are using App Service Plan, you can scale them yourself.
That being said, the current unit of work is based on the Partition Key value ranges. This means that, similar to Event Hub, the parallel processing has a soft limit based on your data distribution.
One way to detect this is to check your leases collection. If you see only one lease (disregard items with .info
or .lock
as their ids), that means your current data distribution yields one partition key value range, and only one instance can be processing that (not matter how many other instances get provisioned).
Logs can also show how scaling is behaving and how are instances picking up the different leases in case there are multiple.
来源:https://stackoverflow.com/questions/56273997/cosmosdb-change-feed-scaling