托管的 WCF 服务有多贵?

发布于 2024-08-21 13:14:38 字数 207 浏览 7 评论 0原文

我和一位同事正在讨论WFC服务,说到“成本”这个话题。

问题是这样的:

鉴于 IIS 托管的 WCF 服务和 Windows 服务托管的 WCF 服务执行完全相同的操作,如果它们都接受相同的内容,则在内存和 CPU 周期方面哪个服务将更加“昂贵”加载?

我们不关心初始启动编码、安装或配置(IIS 似乎旨在提供更简单的体验),只关心运行服务的基本成本。

A co-worker and I are having a discussion about WFC services when the topic of "cost" comes up.

The question is this:

Given that an IIS-hosted WCF service and a Windows-Service-hosted WCF service do the exact same thing, which service will be more "expensive" with regard to memory and CPU cycles if they both are accepting the same load?

We are not concerned about initial start-up coding, installation or configuration (to which IIS seems geared to provide a simpler experience), just the bare-bones cost of running the services.

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

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

发布评论

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

评论(3

北陌 2024-08-28 13:14:38

我无法提供具体数字,但如果这是一个大问题,您绝对应该进行性能测试以确定。对于典型的基于 HTTP 的 WCF 服务,所有请求最初都会由 Windows 内部的 http.sys 处理,然后分派到适当的进程。您的服务是托管在 IIS 中还是独立运行,与您使用的特定于 WCF 的配置设置(关于每次调用、每次会话或单例配置以及请求大小限制和请求限制)无关。

我会关注可用性以及比严格的性能数字更有意义的东西,因为它们应该几乎相同。

底线:使用更方便的方式,必要时进行性能测试。

I cannot provide concrete figures, though if this is big concern, you should definitely do performance testing to be sure. For a typical HTTP-based WCF service, all requests will be initially handled by http.sys inside Windows, and then dispatched to the appropriate process. Whether or not your service is hosted in IIS or standalone will not matter nearly as much as the WCF-specific configuration settings you use, with respect to per-call, per-session or singleton configuration, and request size limits and request throttling.

I would focus on usability and what makes more sense than strictly on performance numbers, since they should be nearly the same.

Bottom line: use whatever is more convenient, performance test when necessary.

时光礼记 2024-08-28 13:14:38

IIS 或基于 Windows 服务的 WCF 托管之间的一项非常重要的性能考虑因素是绑定类型。 IIS 仅支持通过 HTTP 运行的 WCF 绑定,例如 wsHttpBindingbasicHttpBinding 等。

众所周知,非 Http 绑定具有更好的性能,例如 netTcpBinding (我认为服务和客户端都基于 WCF)或 netNamedPipeBinding (最快,但服务/客户端必须位于同一台计算机上)。当然,这些都有其自身的局限性,尤其是灵活性方面。

这是一个很好的概述: http ://weblogs.asp.net/spano/archive/2007/10/02/choosing-the-right-wcf-binding.aspx

这里有一个非常类似的讨论:WCF 绑定性能

One very significant performance consideration between IIS or Windows service based hosting for WCF, is binding type. IIS only supports WCF bindings which function over HTTP, such as wsHttpBinding. basicHttpBinding, etc.

Non-Http bindings are generally known to have better performance, such as the netTcpBinding (requires both service and client to be WCF-based I believe) or netNamedPipeBinding (fastest, but service/client must be on same machine). These of course have their own limitations, especially with flexibility.

Here's a good overview: http://weblogs.asp.net/spano/archive/2007/10/02/choosing-the-right-wcf-binding.aspx

There has been a very similar discussion here: WCF Binding Performance

独守阴晴ぅ圆缺 2024-08-28 13:14:38

我知道这并不能完全回答你的问题,但我想分享我的经验。

我有一个 Windows 控制台应用程序,在计划时它会调用 IIS 中托管的 WCF 服务。在此体系结构中,IIS 实际上是完全不必要的,只是整个解决方案的一个附加组件。它被包含在解决方案中实际上是出于营销原因,为了增强产品,而不是出于技术原因。

这些是我面临的主要问题,以及为什么我会出于技术原因避免使用 IIS(如果可以的话),这也适用于我的经验。请注意:我并不是说在 IIS 中托管 WCF 服务是一个坏主意。我只是根据我目前正在开发的产品发表我的想法。

  1. 在循环中包含 IIS 意味着在整个解决方案中包含另一个系统。这反过来又增加了部署的复杂性。一些客户端运行 IIS6,其他客户端则运行 7。虽然这些差异表面上看起来似乎很小。毫无疑问,它们仍然是不同的,这意味着如果您将产品部署到不同的客户端,您将增加更多潜在的环境差异。不要低估这些差异。我什至有客户尝试在 SharePoint 网站集中运行我的 WCF 服务(废话!),问题的关键远比您想象的可能出错。
  2. IIS 还具有 AppPool 考虑因素,可能需要根据产品的复杂性进行配置。该 AppPool 需要一个身份来运行,这又给您的整体解决方案增加了更多的复杂性。
  3. 我遇到了一些问题,其中单线程服务有时会出现“有趣的” - 线程中止消息。虽然我仍在试图找出确切的原因,但在我内心深处,我真诚地希望这与 IIS 无关。关键是,如果我从整体解决方案中删除 IIS,我就不会考虑这一点。
  4. 我听说过这样的讨论:与自托管相比,IIS 是 WCF 服务更强大的托管环境。我不完全确定这有什么分量。如果您知道自己在做什么,那么您的自托管服务就没有理由不可靠。但我想,实现 IIS 中的一些自动功能(例如 WP 回收)需要更多的前期工作。
  5. 我对循环中的 IIS 总体来说并不是不满意,但是当我将产品交付部署时,这很痛苦,并且没有强大技术背景的顾问必须设置 IIS 应用程序。通常,某些事情可能并且将会出错,并且需要具有更多技术经验的人员介入并解决。如果您是自托管,则可以更轻松地打包应用程序以进行部署。
  6. 抱歉重申一下,如果您选择 IIS,您的解决方案中将有 2 个应用程序,而不是 1 个,即使您组织的业务部门仅将应用程序视为一个业务单元,本质上并不了解解决方案的全部复杂性你正在实施。例如:为什么我们有2个配置文件?为什么我们必须配置邮件两次?为什么我们必须将 DLL 部署到 2 个位置。这些问题被很多人问到。
  7. 最后我想我要提一下,如果您远程工作或通过 VPN 部署到客户端,情况会变得更糟,有时顾问可以访问您无法访问的敏感区域。作为开发人员,请尝试从整体解决方案中消除尽可能多的额外负担。我们还要提一下,系统管理员有时可能会发出方便的 IIS 重置,如果您的应用程序与其他应用程序一起托管,他们会重置您的服务。

根据我的经验,系统越少=出错的可能性就越小。但您需要确定您是否有能力实施可靠的自托管服务。这一切又直接关系到开发、部署和维护的成本。

I know this doesn't answer your question completely, but I would like to share my experience.

I have a windows console application that when scheduled is calling WCF services hosted in IIS. In this architecture the IIS is actually completely unnecessary and just an additional component to the overall solution. It was really included in the solution for marketing reasons, to beef up the product, and not for technical reasons.

These are the main problems I am facing, and why I would have avoided using IIS if I could for technical reasons, and this applies to my experience. Please note: I am not saying hosting WCF services in IIS is a bad idea. I am just giving my thoughts from the product I am working on at present.

  1. Having IIS in the loop means having another system in the overall solution. This in turn adds complexity to your deployment. Some clients have IIS6 others run 7. While these differences might seem small on the surface. Make no mistake, they're still different, meaning you're adding more potential for environment differences if you're deploying your product to different clients. DO NOT underestimate these differences. Ive even have clients trying to run my WCF services inside a SharePoint Site Collection (duh!) the point is A LOT more than you think can go wrong.
  2. IIS also has an AppPool consideration, which might need to be configured depending on the complexity of your product. That AppPool needs an identity to run under, adding more complexity again to your overall solution.
  3. I've had some issues where a single threaded service sometimes has "interesting" - Thread abort messages. While I'm still trying to figure out the exact cause, in the back of my mind I'm sincerely hoping this isn't somehow IIS related. The point is I wouldn't have this consideration if I eliminated IIS from the overall solution.
  4. I've heard discussions that IIS is a more robust hosting environment for WCF services vs self hosted. I am not entirely sure this holds any weight. If you know what you're doing there should be no reason for your self hosted service to be unreliable. But I guess it is more work upfront to implement some of the automatic features you get in IIS, for example WP recycling.
  5. I'm not overall dissatisfied with IIS in the loop, but its a pain when I hand the product over for deployment, and consultants without a strong technical background have to set up the IIS application. Usually something can and will go wrong, and involves someone with more technical experience to step in and solve. If you're self hosting you can much more easily package your app for deployment.
  6. Sorry to reiterate but if you go for IIS, you'll have 2 applications in your solution rather than 1, even though the business side of your organisation will only see the app as one business unit, essentially not understanding the full complexity of the solution you're implementing. For example: Why do we have 2 configuration files? Why do we have to configure mail twice? Why do we have to deploy DLLs to 2 locations. These questions get asked a lot.
  7. Lastly I thought I would mention if you're working remotely or over VPN to deploy to clients, the situation gets even worse, sometimes the consultant has access to sensitive areas you don't. As a developer try to eliminate as much extra baggage as possible from your overall solution. Lets also mention the sys admin might at times issue a convenient IIS reset, if your app is hosted alongside others, they'll reset your services.

Less systems in my experience = less can go wrong. But you need to decide if you have the skills to implement reliable self hosted services. This all in turn directly relates to the cost of development, deployment and maintenance.

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