1

I am trying to scale out a continuous webjob. My service plan is set on standard so i am able to scale out 10 instances. The problem is that the webjob does not scale out and at any time, only one is running.

Number of instances: enter image description here

Functions: enter image description here

Function code: enter image description here

moondaisy
  • 3,655
  • 4
  • 30
  • 59
adrian
  • 35
  • 3

2 Answers2

1

According to this article, we could find the reason, please refer to it.

Behind the scenes, TimerTrigger uses the Singleton feature of the WebJobs SDK to ensure that only a single instance of your triggered function is running at any given time. When the JobHost starts up, for each of your TimerTrigger functions a blob lease (the Singleton Lock) is taken. This distrubuted lock ensures that only a single instance of your scheduled function is running at any time.

Joy Wang
  • 31,424
  • 3
  • 13
  • 32
0

I'd use a Continuous WebJob instead of one with TimerTrigger (TimerTrigger means that the Job is NOT Continuous). You have to remove the TimerTrigger from your code.

The Continuous WebJob will be executed on all available instances by default.

In the WebJob code you have to take care about that the messages are properly locked and completed to avoid concurrency issues.

The Peek() method is not very suitable for a parallel processing because messages are not locked or completed and it doesn't care about other locks. Use either Receive() or the event based RegisterMessageHandler() patthern.

Here is some documentation on that: