启用 IIS 7.5 自动启动后,第一个请求仍然很慢
我已在 IIS 配置中的应用程序池上设置 startMode="AlwaysRunning" 属性,并在应用程序上设置 serviceAutoStartEnabled="true" 属性。我什至设置了 serviceAutoStartProvider 并且可以看到“预热”代码正在执行。我还可以看到 w3wp 进程在 iisreset 后自动启动。尽管如此,对我的 ASP.NET MVC 应用程序的第一个请求与没有自动启动时一样慢。我是否遗漏了任何一点,或者有什么方法可以在没有分析器的情况下轻松调试它?
此功能是否会影响首次请求性能?假设工作进程已准备就绪,.NET appdomain 甚至所有 .NET 程序集都已加载,那么第一个请求实际上要完成的大部分工作是什么?
I've set startMode="AlwaysRunning" attribute on my application pool and serviceAutoStartEnabled="true" attribute on my application in IIS configuration. I've even set up serviceAutoStartProvider and can see that "warm up" code is being executed. I also can see that w3wp process auto-starts after iisreset. Still, the first request to my ASP.NET MVC application is exactly as slow as without auto-start. Is there any point I'm missing or any way to easily debug this without a profiler?
Is this feature expected to affect first request performance at all? What is actually the bulk of work to do on the first request, given that the worker process is ready, .NET appdomain and even all .NET assemblies have been loaded?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近一直在研究这个。
据我所知,自动启动功能将导致您的 IIS 工作线程(默认情况下,只是池中的线程)在第一个请求之前进行 JIT 编译。
然而,编译的似乎只是大量的程序集和依赖项,而不一定是任何方法。
当第一个请求发生并且您编写的方法第一次被调用时,JITer 对那些尚未编译的方法执行最终编译。
autoStart 的好处似乎是它可以让 .Net 预先完成 90% 的工作,但是当第一个请求发生并且那些尚未访问的方法第一次运行时,最后 10% 的工作仍然需要付费。
I've been looking into this recently.
As far as I can tell, the autoStart feature will cause your IIS worker threads (by default, just the one for the pool) to JIT compile before the first request.
However, what is compiled appears to be just a bulk of the assemblies and dependencies, but not necessarily any methods.
When that first request happens, and your methods you've written get called for the first time, the JITer performs a final compile on those methods that have not yet been compiled.
The benefit of autoStart appears to be it lets .Net do 90% of the work up-front, but the last 10% is still paid for when the first request happens and those methods that were yet to be accessed get run for the first time.