Huge delay on first browser-request to Mono XSP hosted web-application

旧街凉风 提交于 2019-12-21 18:12:27

问题


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:

  1. 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?
  2. Why is it doing it after each start again?
  3. Can the huge delay be reduced generally somehow?
  4. 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 ;-)


回答1:


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:

mono --aot /usr/lib/mono/1.0/mscorlib.dll
for i in /usr/lib/mono/gac/*/*/*.dll; do mono --aot $i; done



回答2:


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:

aspnet_compiler.exe -p "d:\original website" -v / -c "d:\compiled website"

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)



来源:https://stackoverflow.com/questions/8151835/huge-delay-on-first-browser-request-to-mono-xsp-hosted-web-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!