Charlie Mott

  Home  |   Contact  |   Syndication    |   Login
  20 Posts | 0 Stories | 20 Comments | 0 Trackbacks

News

View Charlie Mott's profile on LinkedIn



Archives

Post Categories

Monday, October 8, 2012 #

Currently, the Azure PaaS does not offer a distributed\resilient task scheduling service.  If you do want to host a task scheduling product\solution off-premise (and ideally use Azure), what are your options?

Update: 09/01/2013 - There is a new way to schedule tasks in Windows Azure using the Scheduler (preview) provided with the Azure Mobile Services. See http://fabriccontroller.net/blog/posts/job-scheduling-in-windows-azure.

Update: 25/01/2013 - Yet another option. The new Azure “Add-on Store” has a scheduler.
See:
http://weblogs.asp.net/scottgu/archive/2013/01/23/windows-azure-store-new-add-ons-and-expanded-availability.aspx.

Update: 13/12/2013 - Finally there is a Windows Azure Scheduler Service.  See: http://weblogs.asp.net/scottgu/archive/2013/12/12/windows-azure-new-scheduler-service-read-access-geo-redundant-storage-and-monitoring-updates.aspx

________________

PaaS

Option 1: Worker Roles

Use a worker role to schedule and execute actions at specific time periods.  There are a few frameworks available to assist with this:

I found the Azure Toolkit option the most simple to implement. 

Step 1 : Create a domain entity implementing IJob for each job to schedule.  In this sample, I asynchronously call a WCF service method.

   1:  namespace Acme.WorkerRole.Jobs
   2:  {
   3:      using AzureToolkit;
   4:      using ScheduledTasksService;
   5:   
   6:      public class UploadEmployeesJob : IJob
   7:      {
   8:          public void Run()
   9:          {
  10:              // Call Tasks Service
  11:              var client = new ScheduledTasksServiceClient("BasicHttpBinding_IScheduledTasksService");
  12:              client.UploadEmployees();
  13:              client.Close();
  14:          }
  15:      }
  16:  }
Step 2 : In the worker role run method, add the jobs to the toolkit engine.
   1:  namespace Acme.WorkerRole
   2:  {
   3:      using AzureToolkit.Engine;
   4:      using Jobs;
   5:   
   6:      public class WorkerRole : WorkerRoleEntryPoint
   7:      {
   8:          public override void Run()
   9:          {
  10:              var engine = new CloudEngine();
  11:   
  12:              // Add Scheduled Jobs (using CronJob syntax - see  http://www.adminschoice.com/crontab-quick-reference).
  13:   
  14:              // 1. Upload Employee job - 8.00 PM every weekday (Mon-Fri)
  15:              engine.WithJobScheduler().ScheduleJob<UploadEmployeesJob>(c => { c.CronSchedule = "0 20 * * 1-5"; });
  16:              // 2. Purge Data job - 10 AM every Saturday
  17:              engine.WithJobScheduler().ScheduleJob<PurgeDataJob>(c => { c.CronSchedule = "0 10 * * 6"; });
  18:              // 3. Process Exceptions job - Every 5 minutes
  19:              engine.WithJobScheduler().ScheduleJob<ProcessExceptionsJob>(c => { c.CronSchedule = "*/5 * * * *"; });
  20:   
  21:              engine.Run();
  22:              base.Run();
  23:          }
  24:      }
  25:  }
Pros Cons
Azure Toolkit option is simple to implement. For the AzureToolkit option, you are limited to a single worker role.  Otherwise, the jobs will be executed multiple times, once for each worker role instance.
  Paying for a continuously running worker role, even if it just processes a single job once a week.  If you only have a few scheduled tasks to run calling asynchronous services hosted in different web roles, an extra small worker role likely to be sufficient.  However, for an extra small worker role this still costs $14.40/month (03/09/2012).

Option 2: Use Scheduled Task on Azure Web Role calling a console app

Setup a Windows Scheduled Task on the Azure Web Role. This calls a console application that calls the WCF service methods that run the task actions. This design is described here:

Pros Cons
Fairly easy to implement. Supportability - I RDC’ed onto the Azure server and stopped the scheduled task. I then rebooted the machine and the task was re-started. I also tried deleting the task and rebooting, the same thing occurred. The only way to permanently guarantee that a task is disabled is to do a fresh deployment. I think this is a major supportability concern.
  Saleability - multiple instances would trigger multiple tasks.
You can only have one instance for the scheduled task web role. The guidance implements setup of the scheduled task as part of a web role instance. But if you have more than one instance in a web role, the task will be triggered multiple times for each scheduled action (once per machine).
Workaround: If we wanted to use scheduled tasks for another client with a saleable WCF service, then we could include the console & tasks scripts in a separate web role (e.g. a empty WCF service with no real purpose to it).

SaaS

Option 3: Azure Marketplace

I thought that someone might be offering this type of service via the Azure marketplace. At the point of writing this blog post, I did not find anyone doing so.

https://datamarket.azure.com/

Pros Cons
  Nobody currently offers this on the Azure Marketplace.

Option 4: Online Job Scheduling Service Provider

There are plenty of online providers that offer this type of service on a pay-as-you-go approach.  Some of these are free for small usage.   Many of these providers are listed here:

http://en.wikipedia.org/wiki/Webcron

Pros Cons
No bespoke development for scheduler. Reliance on third party.

IaaS

Option 5: Setup Scheduling Software on Azure IaaS VM’s

One of job scheduling software offerings could be installed and configured on Azure VM’s.  A list of software options is listed here:

http://en.wikipedia.org/wiki/List_of_job_scheduler_software

Pros Cons
Enterprise distributed\resilient task scheduling service VM Setup and maintenance
  Software Licence Costs

Option 6: VM Gallery

A the time of writing this blog post, I did not spot a VM in the gallery that included pre-installation of any of the above software options.

Pros Cons
  No current VM template.

Summary

For my current project that had a small handful of tasks to schedule with a limited project budget I chose option 1 (a worker role using the Azure Toolkit to schedule tasks). 

If I was building an enterprise scale solution for the future, options 4 and 5 are currently worthy of consideration.

Hopefully, Microsoft will include tasks scheduling in the future as part of their PaaS offerings.