WCF性能第一次呼叫缓慢 [英] WCF Performance Slow for the first call

查看:350
本文介绍了WCF性能第一次呼叫缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IIS7上安装了WCF服务。我注意到第一次调用我的服务总是很慢。随后的通话速度要快得多。可以接受的。

I have a WCF service installed on IIS7. I noticed that the first call to my service is always very very slow. The subsequent calls are much faster & acceptable.

如果一段时间内没有对该服务进行过呼叫,它将再次进入睡眠模式。在此之后,下一次通话需要很长时间。

If there are no calls made to the service for some time, it again goes to sleep mode. After this the next call again takes a long long time.

此问题的任何补救措施?

Any remedies for this problem?

推荐答案

这是因为IIS上的进程管理。当一段时间内没有呼叫时,IIS释放资源并停止该过程。
这就是为什么你会注意到第一次请求和长时间延迟后请求的速度很慢。因为在第一次请求或长时间的静默之后,IIS会从头开始加载所有内容。 JIT编译器运行等等...

It is because of process management on IIS. When there are no calls for certain period of time IIS release the recourses and stops the process. This is why you can notice that it is slow for first request and for requests after a long delay. Because while the first request or after long period of silence IIS loads everything from scratch. JIT complier runs and etc...

另请注意:
当您在IIS上托管WCF服务时,WCF服务享有ASP.NET的所有功能应用。您必须了解这些功能,因为它们可能会导致服务领域出现意外行为。其中一个主要功能是应用程序回收,包括应用程序域回收和过程回收。通过IIS管理控制台,您可以在希望进行回收时配置不同的规则。您可以在内存,准时和处理的请求数量上设置特定阈值。当IIS回收工作进程时,工作进程中的所有应用程序域也将被回收

Also note : When you are hosting WCF services on IIS, the WCF services enjoy all the features of ASP.NET applications. You have to be aware of these features because they can cause unexpected behavior in the services world. One of the major features is application recycling, including application domain recycling and process recycling. Through the IIS Management Console, you can configure different rules when you want the recycling to happen. You can set certain thresholds on memory, on time, and on the amount of processed requests. When IIS recycles a worker process, all the application domains within the worker process will be recycled as well

如果您需要自动启动:Windows Service Control Manager允许您将启动类型设置为自动,这样一旦Windows启动,服务就会启动,而无需在计算机上进行交互式登录。因此,您可以使用Windows服务作为主机。

If you need automatic starting: The Windows Service Control Manager allows you to set the startup type to automatic, so that as soon as Windows starts, the service will be started, without an interactive logon on the machine. So you can use Windows service as a host.

您可以查看更多详细信息托管和使用WCF服务

More details you can check in Hosting and Consuming WCF Services.

这篇关于WCF性能第一次呼叫缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆