Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Unable to limit the maximum number of concurrent service bus messages processed at a time

Open Tyler-V opened this issue 3 years ago • 4 comments

I am using Azure Functions 3.0.13 and referring to the documentation provided

I have one TimerTrigger that runs daily that puts 0...N messages on the service bus that is then processed by a function with a ServiceBusTrigger that consumes said messages.

Using the host.json input provided, however, I can see that all messages are processed at the same time regardless of setting maxConcurrentCalls to 1.

This is causing all functions to run in parallel and resulting in a deadlock on my database.

I can use the decorator [Singleton(Mode = SingletonMode.Function)] to run one at a time however this is affecting my throughput and I would rather be able to control how many messages can be processed in parallel at a time.

Am I misinterpreting the documentation or is this a bug?

host.json

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true
      }
    }
  },
  "functionTimeout": "01:00:00",
  "extensions": {
    "serviceBus": {
      "prefetchCount": 1,
      "messageHandlerOptions": {
        "autoComplete": true,
        "maxConcurrentCalls": 1,
        "maxAutoRenewDuration": "00:05:00"
      },
      "batchOptions": {
        "maxMessageCount": 1,
        "operationTimeout": "00:05:00",
        "autoComplete": true
      }
    },
    "durableTask": {
      "maxConcurrentActivityFunctions": 5,
      "maxConcurrentOrchestratorFunctions": 1
    }
  }
}

Tyler-V avatar Jan 14 '22 17:01 Tyler-V

Hi @Tyler-V , Thank you for your feedback! We will check for the possibilities internally and update you with the findings.

v-bbalaiagar avatar Jan 18 '22 13:01 v-bbalaiagar

Any updates on this @v-bbalaiagar ?

Tyler-V avatar Jan 31 '22 15:01 Tyler-V

Hi @Tyler-V , I checked this internally. We would like to know a hosting plan for your app. Here is the document to check the scaling behaviors of the various hosting plans - https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale#scale

v-bbalaiagar avatar Feb 01 '22 11:02 v-bbalaiagar

@v-bbalaiagar we are using a premium function app as we have some longer running processes and need to have the flexibility to increase the "functionTimeout" property

Tyler-V avatar Feb 24 '22 20:02 Tyler-V