Bikram
Bikram

Reputation: 523

Throttle/restrict serviceBus Queue to triggered the message form ServiceBusTrigger

I have a ServiceBusQueue(SBQ), which gets a lots of message payloads. I have a ServiceBusTrigger(SBT) with accessRights(manage) which continuously polling a message from SBQ.

The problem i am facing is: My SBT(16 instances at once) pick messages(16 messages individually) at one time and create a request to another server(suppose S1). If SBT continuously creates 500-600 requests then the server S1 stops to respond.

I am expecting: I could throttle/restrict to pick the message at once from SBQ so that I indirectly restrict to send the request.

Please share your thoughts, what design should i follow.I couldn't googled the exact solution.

Upvotes: 1

Views: 1079

Answers (1)

Jerry Liu
Jerry Liu

Reputation: 17800

  1. Restrict the maximum concurrent calls of Service Bus Trigger.

    In host.json, add configuration to throttle concurrency(i.e. by default 16 messages at once you have seen). Take an example of v2 function.

    {
      "version": "2.0",
      "extensions": {
        "serviceBus": {
            "messageHandlerOptions": {
                "maxConcurrentCalls": 8
            }
         }
      }
    }
    
  2. Restrict Function host instances count. When the host scales out, each instance has one Service Bus trigger which reads multiple messages concurrently as set above.

    If the trigger is on dedicated App service plan, scale in the instance counts to some small value. For functions on Consumption plan, add App setting WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT with reasonable value(<=5). Of course we can set the count to 1 in order to control the behavior strictly.

  3. If we have control over how the messages are sent, schedule the incoming messages to help decrease the request rate.

  4. Use static clients to reuse connection with the Server S1.

Upvotes: 2

Related Questions