ASP.Net 上的预编译和启动时间

发布于 2024-07-04 06:39:38 字数 426 浏览 15 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

千纸鹤 2024-07-11 06:39:38

@Simon:

  • 该项目是一个网络应用程序。 那么网站的启动速度就会变慢(除了不同的代码组织之外,我不知道它发生过)?
  • 我检查过,当我在调用 aspnet_compiler 后编辑 web.config 时,我不会触及调试值(但是,如果我不触及 web.config,我会检查网站的启动速度是否更快,只是为了使当然)

(我肯定会看看 ngen,我不知道那个工具。)

@Simon:

  • The project is a Web Application. Websites are then slower to startup (I had no idea it had an incidence, beside the different code organization)?
  • I checked, and while I edit the web.config after aspnet_compiler is called, I don't touch the debug value (I will however check the website is not faster to startup if I don't touch the web.config, just to make sure)

(And I will definitely have a look at ngen, I was not aware of that tool.)

oО清风挽发oО 2024-07-11 06:39:38

确保在 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).

遥远的她 2024-07-11 06:39:38

如果您的网站被编译为可更新,您将在虚拟目录中看到一堆 .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.

江湖彼岸 2024-07-11 06:39:38

为了获得最终的响应能力,请勿让您的应用程序关闭。

第一种方法是确保它非常受欢迎,以便总是有人使用它。

或者,从其他地方获取一个微小的保持活动页面作为计划活动可以用来保持您的网站“热”。

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'.

呆° 2024-07-11 06:39:38

确保:

  1. 您使用的是 Web 应用程序项目而不是网站项目,这将为您的代码生成预编译的二进制文件
  2. 您已关闭 web.config 文件中的调试代码生成 - 我猜这是否与当您使用 aspnet_compiler 时,代码可能会重新编译

如果您尝试过这些,您可以尝试在程序集上运行 ngen 从而节省 JIT 时间?

Make sure that:

  1. You are using a Web Application project rather than a Web Site project, this will result in a precompiled binary for your code behind
  2. You have turned off debug code generation in the web.config file - I guess if this is different to when you used aspnet_compiler the code may be recompiled

If you've tried those, you could maybe try running ngen over your assembly thus saving the JIT time?

鸠书 2024-07-11 06:39:38

关键是要确保 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文