Fixing slow initial load for IIS

Cavyn VonDeylen picture Cavyn VonDeylen · Nov 14, 2012 · Viewed 141.4k times · Source

IIS has an annoying feature for low traffic websites where it recycles unused worker processes, causing the first user to the site after some time to get an extremely long delay (30+ seconds).

I've been looking for a solution to the problem and I've found these potential solutions.

A. Use the Application Initialization plugin

B. Use Auto-Start with .NET 4

C. Disable the idle-timeout (under IIS Reset)

D. Precompile the site

I'm wondering which of these is preferred, and more importantly, why are there so many solutions to the same problem? (My guess is they aren't, and I'm just not understanding something correctly).

Edit

Performing C seems to be enough to keep my site warmed up, but I've discovered that the real root of my site's slowness has to do with Entity Framework, which I can't seem to figure out why it's going cold. See this question, which unfortunately hasn't been answered yet has been answered!

I eventually just had to make a warm up script to hit my site occasionally to make sure it stayed speedy.

Answer

Răzvan Flavius Panda picture Răzvan Flavius Panda · Nov 14, 2012

Options A, B and D seem to be in the same category since they only influence the initial start time, they do warmup of the website like compilation and loading of libraries in memory.

Using C, setting the idle timeout, should be enough so that subsequent requests to the server are served fast (restarting the app pool takes quite some time - in the order of seconds).

As far as I know, the timeout exists to save memory that other websites running in parallel on that machine might need. The price being that one time slow load time.

Besides the fact that the app pool gets shutdown in case of user inactivity, the app pool will also recycle by default every 1740 minutes (29 hours).

From technet:

Internet Information Services (IIS) application pools can be periodically recycled to avoid unstable states that can lead to application crashes, hangs, or memory leaks.

As long as app pool recycling is left on, it should be enough. But if you really want top notch performance for most components, you should also use something like the Application Initialization Module you mentioned.