托管的 WCF 服务有多贵?
我和一位同事正在讨论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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我无法提供具体数字,但如果这是一个大问题,您绝对应该进行性能测试以确定。对于典型的基于 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.
IIS 或基于 Windows 服务的 WCF 托管之间的一项非常重要的性能考虑因素是绑定类型。 IIS 仅支持通过 HTTP 运行的 WCF 绑定,例如
wsHttpBinding
。basicHttpBinding
等。众所周知,非 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
我知道这并不能完全回答你的问题,但我想分享我的经验。
我有一个 Windows 控制台应用程序,在计划时它会调用 IIS 中托管的 WCF 服务。在此体系结构中,IIS 实际上是完全不必要的,只是整个解决方案的一个附加组件。它被包含在解决方案中实际上是出于营销原因,为了增强产品,而不是出于技术原因。
这些是我面临的主要问题,以及为什么我会出于技术原因避免使用 IIS(如果可以的话),这也适用于我的经验。请注意:我并不是说在 IIS 中托管 WCF 服务是一个坏主意。我只是根据我目前正在开发的产品发表我的想法。
根据我的经验,系统越少=出错的可能性就越小。但您需要确定您是否有能力实施可靠的自托管服务。这一切又直接关系到开发、部署和维护的成本。
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.
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.