简体   繁体   English

使用.NET 3.5创建什么? Web服务或Windows服务

[英]What to create using .NET 3.5? A Web Service or a Windows Service

I have to create a Web Service that can service around 100,000 clients. 我必须创建一个可以服务大约100,000个客户端的Web服务。 I have been creating Windows Services for quite some time and use WCF binding in them. 我已经创建Windows服务已有相当一段时间,并在其中使用WCF绑定。 The Windows Services use HTTP binding and provide a http end point that can be used by any client that can talk using SOAP. Windows服务使用HTTP绑定并提供一个http端点,任何可以使用SOAP进行通信的客户端都可以使用它。 I am a little confused whether I should create a ASP.NET Web Service or a Windows Service because both of them will provide a HTTP end point. 我是应该创建ASP.NET Web服务还是Windows服务,这使我有些困惑,因为它们两个都将提供HTTP端点。 I think before WCF came around, Web Services used to enjoy the HTTP bindings and the Windows Services were used with remoting etc. 我认为在WCF出现之前,Web服务曾用于HTTP绑定,而Windows Services已用于远程处理等。

If both provide same HTTP end point then what should be the criteria for deciding on the service type? 如果两者都提供相同的HTTP端点,那么确定服务类型的标准应该是什么?

If you're building a high volume application that needs to service 100k clients then you should choose IIS. 如果要构建需要服务10万个客户端的大容量应用程序,则应选择IIS。 IIS has a lot of facilities built in to handle high loads along with enterprise features like authentication and SSL certificates. IIS内置了许多功能来处理高负载,以及身份验证和SSL证书等企业功能。 If you use a Windows Service you'll hvae to roll a lot of that yourself. 如果您使用Windows服务,则需要自己承担很多费用。

You can use WCF with either so it's a decision about which application type suits you better and it definitely sounds like IIS. 您可以将WCF与两者一起使用,这样就可以确定哪种类型的应用程序更适合您,并且绝对听起来像IIS。

The endpoint where your services lives and WCF versus ASP.NET services are two different things. 服务所在的端点与WCF与ASP.NET服务的区别是两件事。 Here is a decent article on the differences between WCF & ASP.NET services. 这是一篇有关WCF和ASP.NET服务之间差异的体面文章 Where your endpoint is hosted is going to be important for you since you are looking for high scalability. 端点的托管位置对您而言将非常重要,因为您正在寻找高可伸缩性。 You should leverage all the great stuff built into IIS7 in terms of scalability and reliability to host your endpoint. 就可伸缩性和可靠性而言,您应该利用IIS7内置的所有出色功能来承载端点。 I don't see a good reason to host it in your own process. 我认为没有必要在您自己的流程中托管它。 It will be a lot of work to develop something that can scale horizontally as easily as IIS7. 开发可以像IIS7一样水平扩展的东西将是很多工作。 Here is a small article on how to host a WCF service in IIS. 这是一篇有关如何在IIS中托管WCF服务的小文章

You should combine all the answers. 您应该合并所有答案。

WCF services can be hosted as both a Windows Service, as well as in IIS. WCF服务既可以作为Windows服务托管,也可以作为IIS托管。 IIS provides you with much more tools to scale and handle large number of requests. IIS为您提供了更多工具来扩展和处理大量请求。 Since you are targeting the web, and have IIS available go and use IIS. 由于您的目标是网络,并且可以使用IIS,因此请使用IIS。

JP's answer contains a link on how to host WCF in IIS, that should clear up the question you had in sipwiz's answer. JP的答案包含有关如何在IIS中托管WCF的链接 ,该链接应该可以消除您在sipwiz的答案中遇到的问题。

So go on and create a ASP.NET web app. 因此,继续创建一个ASP.NET Web应用程序。 And in there create a WCF service (or add a WCF service library project to your solution, and reference that in your ASP.NET web app. 然后在其中创建WCF服务(或将WCF服务库项目添加到您的解决方案中,并在ASP.NET Web应用程序中引用它。

Given the scale of what you're doing, you might want to stick with WCF. 鉴于您的工作规模,您可能要坚持使用WCF。 The ease of configuring different protocols and other framework features such as built in logging should serve you well. 轻松配置不同协议和其他框架功能(例如内置日志记录)应该可以很好地为您服务。

One advantage of using an asmx service is that it's easy to integrate into a web site project. 使用asmx服务的优点之一是易于集成到网站项目中。 If you're on a small scale site with shared hosting, you might not be able to run a WCF service, but you will be able to run an asmx service. 如果您位于具有共享托管的小型站点上,则可能无法运行WCF服务,但可以运行asmx服务。

You should definitively think about scalability here. 您应该在这里明确考虑可伸缩性。 For example: what happens if your system has to be scaled up using a Web farm? 例如:如果必须使用Web场扩展系统,会发生什么? How does the Win service scenario fit into that situation? Win服务方案如何适应这种情况?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM