Reputation:
I want to try out Azure Functions with the following project:
My problem is that the REST API has a rate limiting. So if my function1 puts 100 items in the queue1 and the function2 is called 100 times parallel, my API calls will be blocked. I therefore need some kind of throttling.
How would you achieve that? I could tell function2 to wait a specific time and then add the item back to queue1, but since everything is parallel I might run in to a deadlock?
Thanks in advance for ideas!
Upvotes: 1
Views: 300
Reputation: 35124
is called 100 times parallel
You can limit this (to some extent) by configuring host.json
:
batchSize
for Storage Queues
maxConcurrentCalls
for Service Bus
If that's not enough, you could do something more sofisticated:
Function 1 knows how many items it has to process, so it could calculate the "ideal" distribution of those for the next 30 minutes
When adding messages to queue1, it could set the time when the message should be picked up (ScheduledEnqueueTimeUtc
for Service Bus or initialVisibilityDelay
for CloudQueue
)
Function2 will be called "on schedule" which should prevent throttling, if the total amount of messages is not too high
Upvotes: 2