Using consumption plan. I created a service bus nodejs function trigger app.
I do not use sessions. Tested with two topics - partitioning enabled/disabled.
const timeout = ms => new Promise(res => setTimeout(res, ms))
module.exports = async function(context, mySbMsg) {
context.log('message start:', mySbMsg);
await timeout(60000)
context.log('message done:', mySbMsg);
};
host.json:
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.3.0, 4.0.0)"
},
"extensions": {
"serviceBus": {
"prefetchCount": 1,
"messageHandlerOptions": {
"autoComplete": true,
"maxConcurrentCalls": 5,
"maxAutoRenewDuration": "00:09:30"
}
}
},
"functionTimeout": "00:09:55"
}
With WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
= 1
I expect to see 5 requests/minute per VM running.
Sending 100 messages, I expect to see 5 messages/minute.
I do see 1 vm running in the live metrics. However, I am seeing 1 message a minute in the logs.
CodePudding user response:
Yes @Teebu, "prefetchCount
":1 is the culprit.
Example:
If prefetchCount
is set to 200, maxConcurrentCalls
is set to 16 (assume), then 200 messages will be prefetched to a specific instance, but only 16 messages processed at a time.
Prefetched Messages can be gotten by the MessageSender
whereas the MaxConcurrency
is only processed by the client code.
MaxConcurrentCalls
- how many messages will a single MessageReceiver
process at the same time.
PrefetchCount
- When initiating a call to receive a message, a single MessageReceiver
can retrieve up to how many messages.
To the same value, setting those two is counterproductive
.
PrefetchCount
should be larger than the number of messages processed concurrently.
In a simple:
The maximum number of messages prefetched by the underlying MessageReceiver
utilized by Azure Functions SDK is determined by the prefetchCount
.
To ensure that not too many messages are prefetched and locks are lost while waiting for processing, ensure that prefetchCount
is properly configured with the value defined for maxConcurrentCalls
.