在具有多个实例的Windows Azure中执行Methode [英] Execute Methode in windows azure with multiple instances

查看:58
本文介绍了在具有多个实例的Windows Azure中执行Methode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Windows Azure应用程序中执行作业计划程序方法.所以在我的应用程序中,我正在使用同一应用程序的2个实例.因此,如果我创建一个调度程序,则意味着两个实例都可以执行相同的代码.有可能避免这种执行吗?还是可以在执行代码之前检查其他实例?对于实现,我使用的是c#.Net.

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.

推荐答案

最常见的模式是自选控制器.在这种模式下,当这些进程开始时,它们会尝试在某个对象(例如blob对象)上创建排他租约.第一个获得租约的过程是实际执行需要完成的任何处理的过程.然后,它还将定期更新租约,以确保它仍然是控制者".任何未能获得租约的实例都将进入睡眠状态,然后稍后再检查(几分钟,几秒钟,几小时...),以查看它们是否可以立即获得租约并成为控制器.这允许原始控制器崩溃或关闭,然后另一个实例将接管成为控制器的工作.

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.

这篇关于在具有多个实例的Windows Azure中执行Methode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆