第一次调用的 WCF 性能缓慢 [英] WCF Performance Slow for the first call

查看:54
本文介绍了第一次调用的 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服务控制管理器允许您将启动类型设置为自动,这样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天全站免登陆