10

I know that webjob scales with webapp i.e. if my webapp is running on 5 instances then webjobs will run on 5 instances as well. I just want to know if there is a way of having multiple instances of the webjob within each instance of the website.

Note: I have max the value of JobHostConfiguration.QueuesConfiguration.BatchSize = 32 already.

Now, my webapp is running on 1 instance. Webjobs is processing 32 concurrently. My goal is to process 3*32 = 96 concurrently.

One possible way to achieve this goal could be deploying the same webjobs 3 times(setting a different name for webJobName property), but i am not sure if this will be a good practice. Please point me the appropriate documentation.

  1. What config.Queues.NewBatchThreshold indicate?

  2. What is the default value for config.Queues.NewBatchThreshold ?

  3. For queue processing what should be the recommend value for config.Queues.NewBatchThreshold ?

Shahriar Hossain
  • 935
  • 9
  • 20

1 Answers1

7

Copying Jon's answer from https://github.com/Azure/azure-webjobs-sdk/issues/628:

The NewBatchThreshold is the number of messages to have left to process in the batch before the SDK refreshes the batch.

For example, if your batch size is 20 and NewBatchThreshold is 5, the SDK will grab 20 messages off the queue each time, pass them to your code for you to process them one by one, then when it gets down to the last 5 unprocessed messages (so you've processed 15) it will grab the next 20. See here under "Parallel execution"

By default the NewBatchThreshold is half of BatchSize (see source code) which is why you are seeing a value of 0 for a batch size of 1.

Note that we'd like to make this less confusing, per this issue I just opended.

Community
  • 1
  • 1
David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • 1
    What about the first question? If my business need is to process more then 32, is there any way to process more then that in a single instance? How to run 96 or more then that in concurrently. Looking for some good documentation that describes the best practice of scaling – Ariful Haque Jun 10 '16 at 09:46
  • The maximum number of jobs running in parallel ends up being `NewBatchThreshold+BatchSize`. So by setting `NewBatchThreshold` to a higher number, you can achieve this. – David Ebbo Jun 10 '16 at 14:01
  • @ArifulHaque I think the best practice of scaling is to have more than 1 webjob (website) instance... Imposing the constraint of having a single instance probably violates the best practice. In any case, you probably could achieve a BatchSize > 32 if you implemented multiple queue-triggered functions that do the same thing. – Matthew Feb 14 '17 at 19:15
  • @David - Does BatchSize apply to the webjob process itself or is it per-queue-triggered function? – Matthew Feb 14 '17 at 19:15
  • 1
    @Matt it is set globally in the process (you can't set different limits for different functions), but it applies individually to each queue triggered function. i.e. they run independently of each other. – David Ebbo Feb 15 '17 at 02:40