chuckd
chuckd

Reputation: 14540

Trigger multiple concurrent service bus trigger azure functions without time degradation

I have a service bus trigger function that when receiving a message from the queue will do a simple db call, and then send out emails/sms. Can I run > 1000 calls in my service bus queue to trigger a function to run simultaneously without the run time being affected?

My concern is that I queue up 1000+ messages to trigger my function all at the same time, say 5:00PM to send out emails/sms. If they end up running later because there is so many running threads the users receiving the emails/sms don't get them until 1 hour after the designated time!

Is this a concern and if so is there a remedy? FYI - I know I can make the function run asynchronously, would that make any difference in this scenario?

Upvotes: 1

Views: 1823

Answers (2)

Mikhail Shilkov
Mikhail Shilkov

Reputation: 35134

1000 messages is not a big number. If your e-mail/sms service can handle them fast, the whole batch will be gone relatively quickly. Few things to know though:

  • Functions won't scale to 1000 parallel executions in this case. They will start with 1 instance doing ~16 parallel calls at the same time, and then observe how fast the processing goes, then maybe add a second instance, wait again etc.

  • The exact scaling behavior is not publicly described and can change over time. Thus, YMMV, and you need to test against your specific scenario.

  • Yes, make the functions async whenever you can. I don't expect a huge boost in processing speed just because of that, but it certainly won't hurt.

Bottom line: your scenario doesn't sound like a problem for Functions, but if you need very short latency, you'll have to run a test before relying on it.

Upvotes: 1

Phillip Ngan
Phillip Ngan

Reputation: 16106

I'm assuming you are talking about an Azure Service Bus Binding to an Azure Function. There should be no issue with >1000 Azure Functions firing at the same time. They are a Serverless runtime and should be able to scale greatly if you are running under a consumption model. If you are running the functions in a service plan, you may be limited by the service plan.

In your scenario you are probably more likely to overwhelm the downstream dependencies: the database and SMS sending system, before you overwhelm the Azure Functions infrastructure.

The best thing to do is to do some load testing, and monitor the exceptions coming out of the connections to the database and SMS systems.

Upvotes: 0

Related Questions