ASP.NET MVC – Slow initial load

Typically an application will always take a little extra time to load as the application domain starts up.

Things helping exacerbate this could be anything from poorly written code (IE: Application_Start) to certain libraries you may be using (ORMs for example). How many modules do you have loaded?

For starters check your web.config for the infamous <compilation debug="true">. That can have significant performance ramifications in a production setup. Set it to “false”!

Recommend googling something along the lines of “improving application startup time” and looking for things that may relate to your particular application.

Update from your first comment:

If you’re seeing the application start up again (hangs for a few seconds) after 30 minutes consistently this is likely related to your Application Pool Recycling settings in IIS.

Go into IIS Manager (this assumes v7+):

  1. Application Pools
  2. Right click the pool being used for your application(s)
  3. Select “Recycling”, a window will come up labeled “Recycling
  4. Inspect those settings since they will determine when to
    automatically kill your app pool and have it restart.

In terms of general performance you may want to try:

  1. Adding some debugging statements that spit out elapsed time in your
    Application_Start() method or any other applicable location to try
    to catch what’s taking the longest.
  2. Create a completely clean demo project and deploy it. See if it
    suffers from the same problem. If it doesn’t try introducing more
    and more of your real code until you detect a slowdown.

If you’re really stumped #2 may be your best bet even though it will be probably be the slowest option.

Leave a Comment