27

I am planning to deploy a website to Azure, that will utilize Web Jobs.

If the site is scaled up to run on multiple instances, should I expect the job to be started on all the instances as well (running concurrently), or can I expect there to only be one instance of the job running at a time ? Can this be configured in Azure ?

driis
  • 161,458
  • 45
  • 265
  • 341

1 Answers1

41

I assume you are using Continuous WebJobs and not Manual/Scheduled. In that case, it will run on all the instances at once. For this to happen correctly, you need to be running in Standard mode, and have the Always On setting enabled.

If you don't want it to run on all instances, you can set it to be in 'singleton' mode by creating a file called settings.job alongside your WebJob files. It should contain:

{ "is_singleton": true }

Note that when using the Kudu Process Explorer UI, you are connecting to a single instance, and won't see processes from other instances. Instead, use the Processes UI built in the Preview Portal (https://portal.azure.com/), which shows processes in all instances.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • 1
    Do you imply that Web Jobs that are scheduled will not be spun up on multiple instances as continuos jobs will be? Thanks – DavideB Feb 14 '14 at 10:37
  • 6
    Correct. Scheduled jobs will run exactly once each time the schedule fires. – David Ebbo Feb 14 '14 at 15:55
  • I have a continuous web job and I have two to three large instances running in standard mode with always on... My jobs only ever run on one of the w3wp processes. I need these to scale out but they won't.. Any ideas – Blake Niemyjski Feb 04 '15 at 03:42
  • @BlakeNiemyjski this shouldn't happen unless you set it to run as singleton (http://blogs.msdn.com/b/waws/archive/2014/05/19/how-to-run-a-continuous-webjob-as-a-singleton.aspx). Could you start a new thread on https://social.msdn.microsoft.com/Forums/azure/en-US/home?forum=windowsazurewebsitespreview so we can investigate? It will be easier than in these SO comments :) – David Ebbo Feb 04 '15 at 13:55
  • @DavidEbbo Yes, I'll create a new case. I also created this stack overflow post with more info: http://stackoverflow.com/questions/28313177/autoscaling-continuous-azure-webjobs-not-working – Blake Niemyjski Feb 04 '15 at 14:01
  • 1
    @DavidEbbo I just created a msdn forum post here: https://social.msdn.microsoft.com/Forums/azure/en-US/2b13c972-e5ba-4914-93f1-5064fba0e087/autoscaling-continuous-azure-webjobs-not-working?forum=windowsazurewebsitespreview – Blake Niemyjski Feb 04 '15 at 14:04
  • 1
    question, does the webjob run on single process, or can it run on multiple process (so the webjob application is allowed to create new processes)? Also we be able to increase the instance just to run the webjob without increasing the instance of the webapp? – Shuliyey Apr 24 '15 at 05:41
  • @Shuliyey it can launches more processes. If you want it to scale separately from the webapp, you can put in a different webapp from your real site, and use a different App Service Plan for scaling. – David Ebbo Apr 24 '15 at 13:26
  • 3
    Are there any documentation for `settings.job`? To see what other options are available. – liang Oct 05 '20 at 03:44