简体   繁体   English

WCF服务托管在控制台应用程序中

[英]WCF Service hosted in a Console Application

How much load can a WCF service, hosted in a console application handle? 托管在控制台应用程序中的WCF服务可以处理多少负载? Can it handle incoming requests as much as a WCF hosted on IIS? 它可以像在IIS上托管的WCF一样处理传入的请求吗?

Additional Notes: Can requests arrive concurrently? 附加说明:请求可以同时到达吗?

I have a WCF service hosted in a console app. 我在控制台应用程序中托管了WCF服务。 I call this WCF service from within a web app. 我在Web应用程序中调用此WCF服务。 That web app may have hundreds of requests concurrently. 该Web应用程序可能同时有数百个请求。

I have simulated a load of requests but I couldn't find out if the console app which hosts the WCF service is actually answering them concurrently or sequentially. 我已经模拟了一大堆请求但我无法确定托管WCF服务的控制台应用程序是否实际上同时或按顺序回答它们。

It doesn't matter where the WCF service is hosted. 托管WCF服务的位置无关紧要。 It all depends on the binding, endpoint, endpoint behavior and service behavior settings and, last but not least, on the way you set (via attributes) the instancing mode and concurrency type for your service. 这一切都取决于绑定,端点,端点行为和服务行为设置,最后但并非最不重要的是,您设置(通过属性)服务的实例化模式和并发类型的方式。

These settings are taken over by the ServiceHost instance. 这些设置由ServiceHost实例接管。 Even if it's running in a console app, the application itself is just a container for the ServiceHost which is the one that creates the runtime environment for your WCF service, based on the settings you give it. 即使它在控制台应用程序中运行,应用程序本身也只是ServiceHost的容器,它是根据您提供的设置为WCF服务创建运行时环境的容器。

For what interests you, see here (concurrency and throttling). 对于您感兴趣的内容,请参阅此处 (并发和限制)。 Also, something very extensive on WCF instance modes . 此外, 在WCF实例模式上非常广泛

For performance reasons I recommend you use a singleton service, which you can specify via the InstanceContextMode. 出于性能原因,我建议您使用单例服务,您可以通过InstanceContextMode指定。 If you have hundreds of requests coming in, it won't do any good to concurrency if a service instance is created for each request. 如果您有数百个请求进入,如果为每个请求创建服务实例,则对并发性没有任何好处。 You have to analyze if singleton is possible in your case by checking if all your service operations are thread safe. 您必须通过检查所有服务操作是否是线程安全的来分析单例是否可行。

How much load can a WCF service, hosted in a console application handle? 托管在控制台应用程序中的WCF服务可以处理多少负载?

As much as your computer can for self-hosted WCF service. 您的计算机可以用于自托管WCF服务。

The host can be a console app or windows service, doesn't matter, from load perspective they are the same. 主机可以是控制台应用程序或Windows服务,无所谓,从加载角度来看它们是相同的。

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

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