Zach
Zach

Reputation: 1321

My azure function app with a queue trigger not scaling out on app service plan

I have a queue with 6 million messages to be processed in azure. I have a function app running in an app plan with a queue trigger. The app service plan will scale out to additional instances when the CPU gets too high. My app plan is running around 10-20% cpu usage. I was previously having an issue where the function was blocking due to the network calls inside the function which caused CPU to skyrocket and my app service plan would scale out. I resolved this by using async code, so now I have this low cpu usage and a very fast function execution time.

I am currently seeing about 1k messages processed a minute, sometimes it will go up to 2k for a bit and then back down. Are there any reasons why my function wouldn't scale up?

Upvotes: 0

Views: 1968

Answers (1)

rickvdbosch
rickvdbosch

Reputation: 15551

Your question also holds the answer:

The app service plan will scale out to additional instances when the CPU gets too high.

and

My app plan is running around 10-20% cpu usage.

Long story short: I think you're scaling on the wrong metric. As @evilSnobu suggested, you could scale on the number of messages in your queue. Some extra info on Consumption Plans that might be interesting:

Runtime scaling
Azure Functions uses a component called the scale controller to monitor the rate of events and determine whether to scale out or scale down. The scale controller uses heuristics for each trigger type. For example, when you're using an Azure Queue storage trigger, it scales based on the queue length and the age of the oldest queue message.
Taken from Azure Functions Consumption and App Service plans

Upvotes: 3

Related Questions