Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC: First access after some minutes slow, then every following request is fast

Tags:

when I access any page of my ASP.NET MVC website first time, then this first request is slow. It needs about 4-5 seconds to load. But every following request to any page is fast.

When I wait some minutes or a hour then every first request is slow again. Every following request is fast.

I think that IIS 7 is compiling the code and keep it in memory. After some time it will delete it from memory so it needs to compile it again.

What can I do that every first request is as fast as every following request? (Without precompiling my source, if possible)

Thank you very much in advance!

like image 302
Chris Avatar asked Jul 30 '10 17:07

Chris


People also ask

Why are ASP Net Applications slightly slower on first 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?

Why is my asp net site 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.


1 Answers

If this is a production server then why not try adding a website monitor; such as up time robot. It basically asks for your websites headers and gets status codes like "200-ok", "404-not found", etc. every 5 minutes. This way your site is always spun up and does not impact log files/analytics as only headers are requested. I use this for my cloud sites as I find that they take 5 seconds to spin up which has an impact on site loading. With the monitor they are instant.

Oh and its free for up to 50 sites!

like image 143
Rippo Avatar answered Oct 28 '22 07:10

Rippo