Question

When using our MVC Web Application after it is updated, it takes several minutes to load the homepage for de first time. After the first load it loads pretty fast. Probably the MSIL code is compiled to Native Machine code and is cached. (Correct me if i'm wrong). This occures for every page.

Everytime a new version is copied over to the server it is very slow. To solve this problem i was trying to get it pre-jit-compiled with ngen so we could save lots time for our users. However when executing "ngen install mydll.dll" for every dll in it's project bin folder, it gives me several errors. This is the command

cd "C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
for %%i in (C:\inetpub\wwwroot\myproject\bin\*.dll) do ngen install "%%i"

The first errors are:

Failed to load dependency System.Web.Mvc of assembly DotNetOpenAuth.Core, 
Version=4.3.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246 because of the following error : The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Failed to load dependency log4net of assembly DotNetOpenAuth.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246 because of the following error : The system cannot find the file specified. (Exception from  HRESULT: 0x80070002)

The project just debugs and builds fine. What is the correct way to achieve this?

Was it helpful?

Solution

You would have to warm-up the initialization of your web application. This will speed-up the load of the homepage for the first time. To give you a brief conceptual overview:

1)The worker process is not spawned until the first request is made to the website . The Worker Process is associated with Application Pool. The spawning of the worker process can be time taking process, as the process initiates the web site. So the first step is to spawn the worker process in advance (w3wp.exe). This can be done at the application pool level

2)With the first request to the website; the worker process loads all the application DLL's to execute the request. This process of loading the dll's can be time taking. Also, when App Pool is recycled , the worker process has to again reload all the application dlls. So the second step is to pre-load the dll's by the worker process.. This can be done at the website level.

The application warm-up module is a built in feature in IIS 8.0.

Please follow below links to warm-up your web application in IIS:

http://technet.microsoft.com/en-us/video/microsoft-virtual-academy-ii8-application-initialization.aspx

http://blogs.msdn.com/b/amol/archive/2013/01/25/application-initialization-ui-for-iis-7-5.aspx

http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-application-initialization

http://weblog.west-wind.com/posts/2013/Oct/02/Use-IIS-Application-Initialization-for-keeping-ASPNET-Apps-alive

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top