How to resolve Service Bus throttling

Suresh Thakur, Kirti 86 Reputation points
2023-12-22T17:28:50.5566667+00:00

I am using service bus trigger function app

My function app gets around 2.3k request at given point of time.

The fn app gets message from service bus topic.

Now we have scaled function app if the load increases.

Max brust is 100.

But still when load is high service bus throttling is happening.

We are using AMQP and EP3 app serviceplan.

How to resolve this.

Error -

Cannot allocate more handles to the current session or connection.The maximum number of handles allowed is 4999.

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
700 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,929 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Taimoor Janjua 6 Reputation points Microsoft Employee
    2023-12-22T22:35:40.4566667+00:00

    Hi @Suresh Thakur, Kirti thanks for reaching out!

    From your question it's not clear that your workload is running on dev | prod environment. I would assume it's a dev environment and your SB is configured with standard tier. The error indicates that you're exceeding the max number of concurrent connections on an SB namespace which is 5000. I believe partitioning is enabled right?? I see some architectural issues here...

    To handle the Throttling please consider following suggestions:

    • Enable retry mechanism to handle the transient errors -> here is the link
    • Instead of scaling out the func app, consider processing messages in batch
    • Enable prefetchCount setting in host.json (it specifies the number of messages the func will fetch and hold in memory at a time), fetching multiple messages at once we can reduce the number of roundtrips, improving the throughput and reducing latency. Please don't set it to some higher number!
    • For Initial setup try the following in your host.json and adjust accordingly
    { 
        "serviceBus": {
          "maxConcurrentCalls": 16,
          "prefetchCount": 100,
          "autoRenewTimeout": "00:05:00",
          "autoComplete": true
        }
    }
    

    Hope that helps!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.