对 Mono XSP 托管 Web 应用程序的第一个浏览器请求出现巨大延迟
我们使用 Mono (2.10) XSP4 Web 服务器来托管在开放式嵌入式 Linux (ARM) 上运行的 ASP.Net MVC3 Web 应用程序。启动 XSP4 时,需要几秒钟的时间才能准备好并接受请求。到目前为止没有问题。
但是,当来自浏览器/网站访问者的第一个请求时,XSP4 会使用它可以获得的所有 CPU 大约 55 秒,直到网页(成功)显示在网络浏览器中。每次启动/重新启动 XSP 后都会发生这种情况。
我的第一个想法是,这是整个 Web 应用程序的即时编译。因此,我构建了一个仅包含二进制文件、.css、.js 和视图 (.cshtml) 的部署包。它有效,但仍然有很大的延迟。
然后我尝试使用 Visual Studio 预编译该 Web 应用程序(如某些 Mono 发行说明中所述)。该网站再次运行良好,但仍然存在巨大的延迟。
我实际上想到的一些问题:
- 有人知道当第一个浏览器请求传入时 XSP Web 服务器在做什么吗?即使它是预编译的 Web 应用程序,这也是即时编译吗?
- 为什么每次启动后都会这样?
- 一般来说,是否可以以某种方式减少巨大的延迟?
- 是否可以减少巨大的延迟,以便仅在 Web 应用程序更新后的第一个浏览器请求上完成(在 XSP 的后续运行之间缓存)?
任何帮助/想法都会很棒。
更新:同时,我发现延迟是由 Mono / ASP.Net 编译器 dcms 构建并将 MVC3 razor 视图编译到 /tmp/root-aspnet.../ 造成的,该视图映射到记忆,因此不是持久的。我现在正在寻找一种方法来控制 XSP4 / Mono.WebServer / Mono-Asp.Net 存储这些编译文件的位置。如果有人熟悉这一点,请告诉我;-)
We are using the Mono (2.10) XSP4 webserver to host an ASP.Net MVC3 web-application running on an open-embedded Linux (ARM). When starting XSP4 it takes some seconds until it is ready and accepts requests. No problem with that so far.
But when the first request from a browser / website-visitor is made XSP4 uses all CPU it can get for about 55 seconds until the webpage is (successfully) shown in the webbrowser. This happens after each start/restart of XSP.
My first thought was that this is the just-in-time compiling of the entire web-application. So I built a deployment package that only contains the the binaries, .css, .js and the views (.cshtml). It worked but still had this huge delay.
Then I tried to pre-compile that web-application using Visual Studio (as stated in some Mono release notes). Again the website worked well but the huge delay was still present.
Some questions that are actually in my mind:
- Does anybody know what the XSP webserver is doing when the first browser-request is coming in? Is this the just-in-time compilation even if its a pre-compiled webapplication?
- Why is it doing it after each start again?
- Can the huge delay be reduced generally somehow?
- Can the huge delay be reduced so it is only done on the very first browser request after a webapplication update (cached between subsequent runs of XSP)?
Any help/ideas would be great.
Update: In the meanwhile I found that the delay is caused by the Mono / ASP.Net compiler dcms building and compiling the MVC3 razor views into /tmp/root-aspnet.../ which is mapped to memory and therefore is not persistent. I am now looking for a way to control where XSP4 / Mono.WebServer / Mono-Asp.Net stores these compiled files. If anybody is familiar with this let me know ;-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能是本机编译开销(与预编译的作用是分开的)。您可以检查AOTing 系统库是否可以提高速度:
This might be native compilation overhead (which is separate from what pre-compiling does). You could check if AOTing the system libraries give you a speedup:
为了防止树莓派在每次 XSP4 启动时编译您的网站,您必须使用
aspnet_compiler.exe
预编译您的网站,该文件位于%WINDIR%\Microsoft.NET\Framework\v4 中。 0.30319
文件夹。这是一个示例:
编译您的网站后,将其上传到您的树莓派,XSP/mono 将使用您网站的编译版本。您的第一个请求会快得多。
以下是一些参考链接:
预编译您的网站 (C#)
ASP.NET 编译工具 (Aspnet_compiler.exe)
To prevent the raspberry to compile your website every time XSP4 is starting, you must precompile your website using
aspnet_compiler.exe
and is located in the%WINDIR%\Microsoft.NET\Framework\v4.0.30319
folder.Here is an example:
Once your website is compiled, upload it to your raspberry and XSP/mono will use the compiled version of your site. Your first request will be much faster.
Here is few reference links:
Precompiling Your Website (C#)
ASP.NET Compilation Tool (Aspnet_compiler.exe)