Asp.net website first start is very slow

The first time I load the website in the production web server, it start very slow, subsequent pages load very quickly (included the home page).

I precompiled the site, but nothing changes.

I don’t have any code at Application start.
I don’t have cached items.

Any ideas? How can I find out what is happening?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

It’s just your app domain loading up and loading any binaries into memory. Also, it’s initializing static variables, so if you have a static variable that loads up a lot of data from the db, it might take a bit.

Method 2

When you published the site, did you choose to make the website “updatable” in the publish website’s settings or not? If I remember well, the aspx / ascx file need to be compiled as well, and if they are “updatable” then the first start will cause a recompile of those resources.

Method 3

Have you turned on tracing in your web.config?

Method 4

Try clearing your event log?

Method 5

use http://www.iis.net/expand/ApplicationWarmUp for warming up your app
this is for IIS 7.5 – so if you are running on Server R2 then it will work.

Method 6

Make sure you publish your application in ‘release’ and not ‘debug’. I’ve noticed this decreases loading time considerably. The web.config file will be updated.

Method 7

This sounds very much like background compiling; though if you’re precompiling, that shouldn’t be an issue.

First thing I would look at is your ORM (if any). NHibernate, in particular, has a serious startup penalty, as it runs multiple compilers in the background at startup to turn each class in your data layer into its own in-memory assembly.

Method 8

Just a quick nod at Darren. That’s typical behavior of a .NET app after a DLL update is made. After the initial load everything should zip along just fine.

Method 9

When you say “precompile” the site, are you using the aspnet_compiler utility to precompile, or simply using the “Build site” option in Visual Studio?

If you are not carrying out the former, I recommend giving it a spin. Coupled with Web Deployment Projects, you should have an easier time deploying your site for each release.

Method 10

The initial slowness is a couple things:

  • The appDomain is being setup
  • ASP.NET is parsing and compiling the ASPX pages.
  • Global Contexts are being initialized.

This is normal behavior for ASP.NET.

Method 11

@Mickey: No, it is turned off. Do I need to turn it on to find out?

The trace log will show you how long each action takes. It could help you find what is taking so long.

Here is a link that might help you get it setup.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x