在 Windows Azure 中:什么是 Web 角色、辅助角色和 VM 角色?

发布于 2024-11-30 18:36:06 字数 120 浏览 2 评论 0原文

我工作的应用程序包含一个 Web 角色:它是一个简单的 Web 应用程序。我需要在 Windows Azure 中托管该应用程序,因此我创建了一个 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

合久必婚 2024-12-07 18:36:06

编辑 2013 年 3 月 3 日 - 更新以引用 UDP 端点、虚拟机和更多语言

编辑 2013 年 6 月 6 日 - 更新以反映 VM 角色的终止,并更新到 web/ Windows Server 2012 的辅助角色基准操作系统映像

@Vladimir 提供的良好链接。需要澄清一点:所有角色(Web、工作者)本质上都是 Windows Server。 Web 角色和辅助角色几乎相同:

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

要回答有关如何处理这些角色的问题:平台培训套件(下面提到)将为您提供很多好的想法和示例,但这里有一些简单的用例:

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

对于 Web 和 Worker 角色,操作系统和相关补丁都会为您处理;您无需管理虚拟机即可构建应用程序的组件。

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

使用虚拟机,您可以只需从图库中选择一个操作系统映像,系统会为您创建该映像并将其作为 vhd 存储在 blob 存储中。然后,您可以使用 RDP/ssh 并按照自己的喜好进行设置。

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

为了获得良好的开端,请查看平台培训套件 并开始逐步完成练习。

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.

独孤求败 2024-12-07 18:36:06
  • Web 角色是托管在 IIS 中的 Web 应用程序。
  • 辅助角色是可以执行某些工作的进程(即自动压缩上传的图像、每当数据库中发生更改时执行操作、从队列中获取新消息并进行处理等等)
  • VM 角色托管 VM
  • Web roles are web applications hosted in IIS.
  • Worker roles are processes that can do some work (i.e. automatically compress uploaded images, do stuff whenever something changes in your database, get new messages from queue and process, you name it)
  • VM roles host VMs
迷乱花海 2024-12-07 18:36:06

几天前我遇到了这个问题/答案,我发现提供的答案有点超出我的理解(我是 Azure 和 Web 的新手)。今晚我在 Azure 基础知识中发现了这个摘要,我认为这是对辅助角色和 Web 角色之间核心差异的一个很好的高级概述:

两者之间的主要区别在于 Web 角色的实例
运行 IIS,而辅助角色的实例则不运行。两者都是
然而,以相同的方式管理,这对于应用程序来说很常见
两者都使用。例如,Web 角色实例可能接受请求
来自用户,然后将它们传递给辅助角色实例进行处理。
要扩大或缩小应用程序的规模,您可以请求 Windows
Azure 创建更多任一角色的实例或关闭现有角色
实例。与 Windows Azure 虚拟机类似,您
仅按每个 Web 或辅助角色实例运行的时间收费
正在运行。

如果您是 Azure 开发新手,我强烈建议您阅读此处的完整文章:Windows Azure 简介

我希望这对某人有帮助,就像它对我的启发一样。

I ran across this SO question/answer several days ago and I found the answers provided a bit over my head (I'm new at Azure and Web). I found this summary in the Azure fundamentals tonight which I thought was a good high level overview of the core differences between the worker and web roles:

The main difference between the two is that an instance of a web role
runs IIS, while an instance of a worker role does not. Both are
managed in the same way, however, and it's common for an application
to use both. For example, a web role instance might accept requests
from users, then pass them to a worker role instance for processing.
To scale your application up or down, you can request that Windows
Azure create more instances of either role or shut down existing
instances. And similar to Windows Azure Virtual Machines, you're
charged only for the time that each web or worker role instance is
running.

If you're new at Azure development I highly recommend reading the full article here: Intro to Windows Azure

I hope this helps someone as much as it helped turn the light bulb on for me.

じее 2024-12-07 18:36:06

Windows Azure 中的 Web 角色具有特殊用途,并提供专用的 Internet 信息服务 (IIS) Web 服务器,用于托管前端 Web 应用程序。您可以快速轻松地将 Web 应用程序部署到 Web 角色,然后扩展或缩减计算功能以满足需求。

Web roles in Windows Azure are special purpose, and provide a dedicated Internet Information Services (IIS) web-server used for hosting front-end web applications. You can quickly and easily deploy web applications to Web Roles and then scale your Compute capabilities up or down to meet demand.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文