每个实例运行多个WorkerRoles [英] Run multiple WorkerRoles per instance

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

问题描述

我有几个 WorkerRole ,只有很短的时间做工作,这将是浪费钱把他们在每一个实例。我们可以在一个单一合并他们,但它会是一个烂摊子,并在遥远的未来,他们都应该独立工作,当负载增加。

I have several WorkerRole that only do job for a short time, and it would be a waste of money to put them in a single instance each. We could merge them in a single one, but it'd be a mess and in the far future they are supposed to work independently when the load increases.

有没有一种方法来创建您可以创建一个多站点 WebRole WorkerRole C $ C>?

Is there a way to create a "multi role" WorkerRole in the same way you can create a "multi site" WebRole?

在负的情况下,我想我可以创建一个师傅的角色,即能够从给定文件夹加载程序集,寻找RoleEntryPoint推导与反思类,创建实例并调用 .RUN() .OnStart()方法。这种师傅作用也将再次抛出意外的异常,并调用 .OnStop()中的所有子 RoleEntryPoint S当 .OnStop()被称为主之一。将它的工作?我应该怎么知道的?

In negative case, I think I can create a "master worker role", that is able to load the assemblies from a given folder, look for RoleEntryPoint derivated classes with reflection, create instances and invoke the .Run() or .OnStart() method. This "master worker role" will also rethrown unexpected exceptions, and call .OnStop() in all sub RoleEntryPoints when .OnStop() is called in the master one. Would it work? What should I be aware of?

推荐答案

正如其他人所说,这是最大限度地提高您的实例利用一个非常普遍的技术。有可能的例子和框架抽象工人基础设施,要进行,其中包括这(我们的)样品中的实际工作:<一href=\"http://msdn.microsoft.com/en-us/library/ff966483.aspx\">http://msdn.microsoft.com/en-us/library/ff966483.aspx (向下滚动到实施内部)

As mentioned by others, this is a very common technique for maximizing utilization of your instances. There may examples and "frameworks" that abstract the worker infrastructure and the actual work you want to be done, including one in this (our) sample: http://msdn.microsoft.com/en-us/library/ff966483.aspx (scroll down to "inside the implementation")

特触发工作最常用的方法是:

Te most common ways of triggering work are:


  1. 时间安排工人(如cron的
    作业)

  2. 信息baseds工人(通过消息的presence触发工作)。

上面提到的code样品实现了#2进一步抽象和易于扩展的#1。

The code sample mentioned above implements further abstractions for #2 and is easily extensible for #1.

请记住,虽然与队列中的所有交互都基于轮询。工人不会在队列中一个新的消息醒来。你需要积极地查询队列中是否有新邮件。查询过于频繁会令微软开心,但可能不是你:-)。每个查询算作是计费事务(这些= $ 0.01 10K)。一个好的做法是轮询消息队列某种延迟回退的。另外,获取消息的批次。

Bear in mind though that all interactions with queues are based on polling. The worker will not wake up with a new message on the queue. You need to actively query the queue for new messages. Querying too often will make Microsoft happy, but probably not you :-). Each query counts as a transaction that is billed (10K of those = $0.01). A good practice is to poll the queue for messages with some kind of delayed back-off. Also, get messages in batches.

最后,服用此发挥到了极致,还可以结合Web角色和辅助角色的一个实例。看到这里的一个例子:<一href=\"http://blog.smarx.com/posts/web-page-image-capture-in-windows-azure\">http://blog.smarx.com/posts/web-page-image-capture-in-windows-azure

Finally, taking this to an extreme, you can also combine web roles and worker roles in a single instance. See here for an example: http://blog.smarx.com/posts/web-page-image-capture-in-windows-azure

这篇关于每个实例运行多个WorkerRoles的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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