Reputation: 75
I am using azure worker role with auto scale.. When more than one instance running, performance is good. But some function should not run in same time. so i need to make a method or task as sync, or need to lock until another one finished.. Need to implement this across multiple azure instance.. Or specific function should run in only one instance.
How to implement this?
Thank you
Upvotes: 2
Views: 243
Reputation: 136146
Since each instance runs independently, I don't think making a method or task sync is going to help you out as each method or task will run synchronously in each instance.
Do take a look at Leader Election Pattern
(and while you're there, do take a look at other cloud patterns as well). Essentially the idea is that each instance will fight (for the lack of better word :)) to execute a method but only once instance will succeed. The instance which will succeed is the Leader
and will execute the method. There are two ways by which you can implement this:
GET
message from this queue but only one instance will GET
the message. The instance which gets the message will execute the method.Upvotes: 1