Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET application on IIS7 - very slow startup after iisreset

I have an ASP.NET 3.5 website running under IIS7 on Windows 2008.

When I restart IIS (iisreset), then hit a page, the initial startup is really slow.

I see the following activity in Process Explorer:

  • w3wp.exe spawns, but shows 0% CPU activity for about 60 seconds
  • Finally, w3wp.exe goes to 50% CPU for about 5 seconds and then the page loads.

I don't see any other processes using CPU during this time either. It basically just hangs.

What's going on during all that time? How can I track down what is taking all this time?

like image 545
frankadelic Avatar asked Sep 17 '09 22:09

frankadelic


People also ask

Why is my asp net web application so slow?

There can be numerous reasons why . NET applications can be slow. These include incorrect memory sizing, GC pauses, code-level errors, excessive logging of exceptions, high usage of synchronized blocks, IIS server bottlenecks, and so on.

Does Iisreset restart application pool?

Does IISRESET recycle the application pools? The correct answer is no. Instead, IISRESET causes the shutdown of all active IIS worker processes, kills them if they do not stop in time.

Do I need to restart IIS after changing web config?

Changes to the web. config will trigger the app to be reloaded by IIS as soon as there are 0 connections left to the app. You can also stop and restart the app pool that the app is assigned to in order to make this happen. You do not need to stop and restart IIS itself.

Why is my IIS hosted site so slow on first load?

Causes of IIS website slow to load issue This can be due to faulty website code, resource crunch on the server, bad server settings, etc. Many times, the end result that we see as slowness will be a combination of many factors.


4 Answers

We had a similar problem and it turned out to be Windows timing out checking for the revocation of signing certificates. Check to see if your server is trying to call out somewhere (e.g. crl.microsoft.com). Perhaps you have a proxy setting incorrect? Or a firewall in the way? We ultimately determined we had enough control over the server and did not want to 'call home', so we simply disabled the check. You can do this with .NET 2.0 SP1 and later by adding the following to the machine.config.

<runtime> <generatePublisherEvidence enabled="false"/> </runtime>

I am not sure if you can just put this in your app.config/web.config.

like image 103
Sebastian Good Avatar answered Oct 16 '22 11:10

Sebastian Good


IL is being converted into machine native code (Assembly) by the Just-In-Time compiler and you get to wait while all the magic happens.

When compiling the source code to managed code, the compiler translates the source into Microsoft intermediate language (MSIL). This is a CPU-independent set of instructions that can efficiently be converted to native code. Microsoft intermediate language (MSIL) is a translation used as the output of a number of compilers. It is the input to a just-in-time (JIT) compiler. The Common Language Runtime includes a JIT compiler for the conversion of MSIL to native code.

Before Microsoft Intermediate Language (MSIL) can be executed it, must be converted by the .NET Framework just-in-time (JIT) compiler to native code. This is CPU-specific code that runs on the same computer architecture as the JIT compiler. Rather than using time and memory to convert all of the MSIL in a portable executable (PE) file to native code. It converts the MSIL as needed whilst executing, then caches the resulting native code so its accessible for any subsequent calls.

source

like image 26
Ty. Avatar answered Oct 16 '22 09:10

Ty.


Thats the compilation of asp.Net pages into intermediate language + JIT compilation - it only happens the first time the page is loaded. (See http://msdn.microsoft.com/en-us/library/ms366723.aspx)

If it really bothers you then you can stop it from happening by pre-compiling your site.

EDIT: Just re-read the question - 60 seconds is very long, and you would expect to see some processor activity during that time. Check the EventLog for errors / messages in the System and Application destinations. Also try creating a crash dump of the w3wp process during this 60 seconds - there is an chance you might recognise what its doing by looking at some of the call stacks.

If it takes exactly 60 seconds each time then its likely that its waiting for something to time out - 60 seconds is a nice round number. Make sure that it has proper connections to the domain controllers etc...

(If there are some IIS diagnostic tools that would do a better job then I'm afraid I'm not aware of them, this question might be more suited to ServerFault, the above is a much more developer-ish approach to troubleshooting :-p)

like image 4
Justin Avatar answered Oct 16 '22 11:10

Justin


I found that there was a network delay making an initial connection from the front end web server to the database server.

The issue was peculiar to Windows 2008 and our specific network hardware.

The resolution was to disable the following on the web servers:

  • Chimney offload state

  • Receive window auto-tuning level

like image 4
frankadelic Avatar answered Oct 16 '22 10:10

frankadelic