Search code examples
azureazure-webjobsazure-webjobs-triggered

Will webjob scale-in kill "busy" instances?


Let's say I have a webjob that consumes messages from a storage queue. I am planning a scale rule to scale-out when my queue has too many messages waiting to be picked up.

Some of the messages will take a long time to process.

My question is... If scale-out happens and that the scale-in rule kicks in (when the nbr of message in the queue decrease), will Azure wait until the messages have finished processing before killing the instances or it will just kill the instances right away?


Solution

  • Update 01/20:

    For auto-scaling, it doesn't matter, it will wait for the instance to finish it's job.

    But for manually scale-in, it does not wait but kill it right away.


    Original:

    For manually scale-in, no, it does not kill the busy instance. Azure WebApp / webjobs should use a specified LoadBalance strategy for multiple instances, and it will balance the workload and route the queue messages to the 3 instances respectively. That means the 3 instances will work in parallel.

    I didn't find any official document about this, but it's easy to test it out.

    I set up a queue trigger webjob, and upload it as continuous in azure. After scale out, you can see the 3 instances are all working.

    Note: the instance id 940246 is the original one, the other 2 instances id 4c7ed0 / f3753c comes after scale out.

    In the kudu site, the 3 instances are listed there. Screenshot as below:

    enter image description here

    In the webjob logs:

    enter image description here

    enter image description here