在 Windows Azure 中:什么是 Web 角色、辅助角色和 VM 角色? [英] In Windows Azure: What are web role, worker role and VM role?

查看:32
本文介绍了在 Windows Azure 中:什么是 Web 角色、辅助角色和 VM 角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处理的应用程序包含一个网络角色:它是一个简单的网络应用程序.我需要在 Windows Azure 中托管应用程序,因此我创建了一个 Web 角色.我其实很想知道这些角色是干什么用的.它们在编码或存储方面的意义是什么?

解决方案

EDIT 3/3/2013 - 更新以引用 UDP 端点、虚拟机和更多语言

EDIT 6/6/2013 - 更新以反映 VM 角色的终止,并将网络/工作者角色基线操作系统映像更新为 Windows Server 2012

@Vladimir 提供的良好链接.再澄清一点:所有角色(web、worker)本质上都是 Windows Server.Web 和 Worker 角色几乎相同:

  • Web 角色是启用了 IIS 的 Windows Server 虚拟机
  • 辅助角色是禁用 IIS 的 Windows Server VM(您可以手动启用它)
  • VM 角色是您通过 Hyper-V 在本地构建并上传到 Azure 的 Windows Server 2008 映像(现已停产,自 2013 年 5 月 31 日起不再可用
  • 虚拟机是在 Azure 中创建的 Windows 或 Linux 映像,作为 vhd 存储在您自己的存储中,并且对 VM 角色进行了多项增强.例如:由于 vhd 在您自己的存储帐户中,您可以轻松地从您的 vhd 创建图像模板,将其复制到新的 vhd,甚至将其上传到 VM Depot(仅限 Linux).

回答您关于如何处理这些角色的问题:平台培训工具包(如下所述)将为您提供许多好的想法和示例,但这里有一些简单的用例:

  • 您可以运行任何公开 tcp、http、https 或 udp 端点(Web 应用程序、SOAP/REST 服务等)的代码.不过,您需要考虑无状态的做事方式 - 如果您有多个 VM 实例在运行,用户流量将分布在这些实例中.平台培训套件将向您展示如何使用存储或缓存来解决此问题.
  • 您可以运行存在于队列或计时器之外的代码.也许您有按需任务,例如照片的缩略图生成或基于用户输入的计算.这些不需要外部可用的端点.您可以将您的请求推送到一个队列,然后让一个任务运行,该任务只是从这个队列中获取信息(您可以跨多个实例扩展这个过程,所有实例都使用队列消息).
  • 您可以运行 .NET、Java、php、python、node、ruby 等.您只需要将适当的运行时代码与您的项目代码一起分发.所有语言都可以对 Azure API 进行 REST 调用,并且有几种语言(包括上面提到的那些)有 SDK 可以为你处理这个问题.所有语言 SDK 都在这里,在 github 上有源代码,这里.
  • 使用 VM 角色,您可以安装和运行具有非常复杂/耗时的安装、需要手动干预的安装以及无法可靠自动化的安装的软件.在这种情况下,您必须处理操作系统维护.除了 VM 角色之外,现在还有虚拟机,提供基于云的 VM 构建以及 Windows 和 Linux 支持.我建议使用虚拟机而不是 VM 角色.

Web 和 Worker 角色,为您处理操作系统和相关补丁;您无需管理 VM 即可构建应用程序的组件.

使用 VM 角色,您可以构建完整的 Windows Server 映像,向其中添加 Azure 挂钩,然后将整个 VM 推送到云中(然后随着时间的推移维护 VM 映像).>

使用虚拟机,您只需从库中选择一个操作系统映像,该映像会为您创建并作为 vhd 存储在 blob 存储中.然后你 RDP/ssh 并按照你喜欢的方式设置它.

戴着建筑师的帽子,这就是它变得有趣和有趣的地方.您可以在 Web 角色或辅助角色中运行 Web 服务(并且能够在任一角色中打开端口);您可以以 Worker 角色托管 Tomcat 或其他 Web 服务器.您可以选择将网站和服务组合在一个角色中,或者将它们拆分为多个角色以满足不同的可扩展性需求.

作为一个好的开始,请查看 平台培训套件并开始逐步完成练习.

The application I work on contains a web role: it's a simple web application. I needed to host the application in Windows Azure, so I created a web role. I actually want to know what these roles are for. What is their significance coding wise or storage wise?

解决方案

EDIT 3/3/2013 - updated to reference UDP endpoints, Virtual Machines, and more languages

EDIT 6/6/2013 - updated to reflect the discontinuation of VM Role, and update to web/worker role baseline OS images to Windows Server 2012

Good link by @Vladimir. A bit more clarification: All roles (web, worker) are essentially Windows Server. Web and Worker roles are nearly identical:

  • Web roles are Windows Server VMs with IIS enabled
  • Worker roles are Windows Server VMs with IIS disabled (and you could manually enable it)
  • VM roles are Windows Server 2008 images you construct locally via Hyper-V and upload to Azure (and are now discontinued and no longer available as of May 31, 2013
  • Virtual Machines are Windows or Linux images created in Azure, stored as a vhd in your own storage, and have several enhancements over VM role. For example: since the vhd is in your own storage account, you can easily create an image template from your vhd, copy it to a new vhd, or even upload it to VM Depot (Linux only).

To answer your question about what to do with these roles: The Platform Training kit (mentioned below) will give you lots of good ideas and samples, but here are some straightforward use cases:

  • You can run any code that exposes a tcp, http, https, or udp endpoint (web applications, SOAP/REST services, etc.). You need to think about the stateless way of doing things though - if you have more than one VM instance running, user traffic is distributed across those instances. The platform training kit will show you how to use storage or cache to deal with this.
  • You can run code that lives off a queue or a timer. Maybe you have on-demand tasks such as thumbnail-generation of photos, or calculations based on user input. These don't need externally-available endpoints. You can push your requests to a queue, and then have a task running which simply feeds off this queue (and you can scale this process across multiple instances, with queue messages consumed by all instances).
  • You can run .NET, Java, php, python, node, ruby, etc. You just need to distribute the appropriate runtime code along with your project code. All languages can make REST calls to the Azure API, and several languages (including those mentioned above) have SDKs that take care of this for you. All language SDKs are here, with source code on github, here.
  • With a VM role, you can install and run software with very complex/time-consuming installations, installations that require manual intervention, and installations that can't be reliably automated. You must deal with OS maintenance in this case. Beyond VM Role, there are now Virtual Machines, providing cloud-based VM construction along with both Windows and Linux support. I'd suggest Virtual Machines over VM Role.

With Web and Worker roles, the OS and related patches are taken care of for you; you build your app's components without having to manage a VM.

With VM roles, you build a complete Windows Server image, add the Azure hooks to it, and push the entire VM into the cloud (and then maintain the VM image over time).

With Virtual Machines, you simply pick an OS image from a gallery, which gets created for you and stored as a vhd in blob storage. You then RDP/ssh and set it up how you like.

Wearing the architect hat, this is where it gets fun and interesting. You can run web services in a Web Role or worker role (and be able to open ports in either); You can host Tomcat or other web servers in a Worker role. you can choose to combine a website plus services in a single role, or split them into multiple roles for different scalability needs.

For a good start, take a look at the Platform Training Kit and start walking through the exercises.

这篇关于在 Windows Azure 中:什么是 Web 角色、辅助角色和 VM 角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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