My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
TaskScheduler  
Execution scheduling through ScheduledServices.
Updated Mar 16, 2011 by christop...@gmail.com

The problem

A feature frequently found missing from Windows Azure is the availability of a Task Scheduler to automatically trigger operations at specified times.

ScheduledService

Thus, Lokad.Cloud provides ScheduledService that exposes a simple Start method:

public abstract class ScheduledService : CloudService
{
  public abstract void StartOnSchedule();
  // other methods snipped
}

Then, inheritors can be decorated with the ScheduledServicesSettings attribute to specify the execution frequency of the service.

public class ScheduledServiceSettingsAttribute
{
	public TimeSpan TriggerInterval { get; set; }
	public bool SchedulePerWorker { get; set; }
}

ScheduledService supports two scheduling modes:

  • Cloud Scoped: Lokad.Cloud ensures that the service is executed only once, in a single worker, for each scheduled execution time; eventually spreading the execution among many workers if there are frequent coarse grained scheduled operations. This is the default mode and recommended. Enabled if SchedulePerWorker is set to false or not set at all.
  • Worker Scoped: The service is executed once on every worker for each scheduled execution time. The execution is not synchronized between the workers. This mode guarantees that the service will execute on every worker from time to time and is thus intended primarily for worker management tasks. Note that this mode is not recommended for any services that do not need that guarantee. To enable it, set SchedulePerWorker to true.

Also, it must be noted that the value specified by the TriggerInterval can be overridden directly through the Web Admin Console. This feature facilitate the tuning of your app to adjust the tradeoff latency vs I/O costs.

Although Lokad.Cloud is distributing the schedule executions among workers, we suggest keeping scheduled operations as lightweight as possible: the call to Start() must return quickly. If the operation is heavy, then we suggest the ScheduledService to put a message in a queue for a later processing through a distinct QueueService.

Following this guidance will improve the overall load balancing of your cloud app.

Delayed queue messages

The framework also provides the possibility to delay a queue message to be processed later on. Basically, CloudService exposes a method

public abstract CloudService
{
  void PutWithDelay<T>(T item, DateTime trigger);
}

where trigger is used to specify the time where item will actually be put in its corresponding queue (to be later consumed by a QueueService).


Sign in to add a comment
Powered by Google Project Hosting