0

I want to execute a job scheduler methods in my windows azure application. So in my application i am using 2 instance of the same application. So If i create a scheduler means both the instance can execute same code. Is it possible to avoid such execution? Or is it possible check other instace before executing the code? For the implementation i am using c#.Net.

David Makogon
  • 69,407
  • 21
  • 141
  • 189
Hope
  • 1,252
  • 4
  • 17
  • 35
  • possible duplicate of [Azure - how do I run a job that calls a function in the webservice every hour?](http://stackoverflow.com/questions/8548159/azure-how-do-i-run-a-job-that-calls-a-function-in-the-webservice-every-hour) – David Makogon Jun 20 '12 at 15:19
  • Also [cloud scheduler](http://stackoverflow.com/q/6457231/272109) – David Makogon Jun 20 '12 at 15:20
  • Also [how to write azure web role - worker role schedule task?](http://stackoverflow.com/q/9193939/272109) – David Makogon Jun 20 '12 at 15:25

1 Answers1

1

The most common pattern is a self-electing controller. In this pattern, when these processes start, they attempt to create an exclusive lease on something, say a blob object. The fist process to get the lease is the one that actually performs whatever processing needs to be done. It will also then renew the lease periodicaly to make sure it remains the "controller". Any instances that fail to get the lease then go to sleep and check back later (minutes, seconds, hours...) to see if they can get the lease now and become the controller. This allows for the original controller to crash or be shut down and then another instance will take over the job of being the controller.

BrentDaCodeMonkey
  • 5,493
  • 20
  • 18