ASP.Net 上的预编译和启动时间
我正在 ASP.Net 2.0 中开发一个(相对较小的)网站。 在交付可执行文件之前,我还使用 nAnt 对我的项目进行一些简单的调整。 在当前状态下,该网站是使用“预编译”的
aspnet_compiler.exe -nologo -v ${Appname} -u ${target}
我注意到,在 IIS 池重新启动后(空闲关闭或回收后),应用程序最多需要 20恢复联机(并且到达 Application_start)之前的秒数。
当我直接在 Visual Studio 中调试时(启动需要 2 秒),我没有遇到同样的问题,所以我想知道 aspnet_compiler 是否真的是一个好主意。
我在 MSDN 上找不到太多内容。 您如何编译您的网站以进行生产?
I am developping a (relatively small) website in ASP.Net 2.0. I am also using nAnt to perform some easy tweaking on my project before delivering executables. In its current state, the website is "precompiled" using
aspnet_compiler.exe -nologo -v ${Appname} -u ${target}
I have noticed that after the IIS pool is restarted (after a idle shutdown or a recycle), the application takes up to 20 seconds before it is back online (and Application_start is reached).
I don't have the same issue when I am debugging directly within Visual Studio (it takes 2 seconds to start) so I am wondering if the aspnet_compiler is really such a good idea.
I couldn't find much on MSDN. How do you compile your websites for production?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
@Simon:
(我肯定会看看 ngen,我不知道那个工具。)
@Simon:
(And I will definitely have a look at ngen, I was not aware of that tool.)
确保在 web.config
中进行了设置。 就我而言,我还有一个批处理文件,该文件在提供给用户之前发出所有主页的 Get 请求(页面加载模拟)。Make sure this is set in web.config
<compilation debug=false>
. In my case, I also have a batch file which issue Get requests for all the main pages before giving to users (page loading simulation).如果您的网站被编译为可更新,您将在虚拟目录中看到一堆 .ASPX 文件。 这些必须在启动时编译。 这样您就可以进入并更改 Web UI 本身。 这是网站和 Web 应用程序的默认设置。
If your website is compiled as updatable, you'll see a bunch of .ASPX files in your virtual directory. These must be compiled on startup. That's so you can come in and alter the web UI itself. This is default for both websites and web applications.
为了获得最终的响应能力,请勿让您的应用程序关闭。
第一种方法是确保它非常受欢迎,以便总是有人使用它。
或者,从其他地方获取一个微小的保持活动页面作为计划活动可以用来保持您的网站“热”。
For ultimate reponsiveness, don't allow your app to be shutdown.
The first method is to make sure that it's incredibly popular so that there's always someone using it.
Alternatively, fetching a tiny keep-alive page from somewhere else as a scheduled activity can be used to keep your site 'hot'.
确保:
如果您尝试过这些,您可以尝试在程序集上运行 ngen 从而节省 JIT 时间?
Make sure that:
If you've tried those, you could maybe try running ngen over your assembly thus saving the JIT time?
关键是要确保 IIS 应用程序池永远不会关闭。 这是代码实际托管的地方。 将“空闲超时”(在“高级设置”下)设置为非常高的值,例如 1440 分钟(24 小时),以确保只要有人每天访问您的网站一次,它就不会关闭。
每当您部署新代码时,或者如果在没有任何流量的情况下超过此空闲超时期限,您仍然会有 JIT 时间。
配置 IIS 7.x 空闲超时
The key is to make sure the IIS Application Pool never shuts down. This is where the code is actually hosted. Set the "Idle Timeout" (Under Advanced Settings) to something really high, like 1440 minutes (24 hours) to make sure it's not shut down as long as somebody hits your site once a day.
You are still going to have the JIT time whenever you deploy new code, or if this idle timeout period is exceeded witout any traffic.
Configuring IIS 7.x Idle Timeout