3

I have several MVC4 sites on my VPS. They all have the same issue. They are so slow (up to 10 seconds to load, which is not a good first impression).

I am aware that when you first load your site, it will take a little while due to various things I've read upon. I understand this.

The problem is the following situation is true.

Publish MVC4 site to server.
Load MVC4 site in browser a PC. Site takes a while to load but expected.
Look at other pages on the site. A few are slow, but generally all is OK.
Close the website.
Reopen the website.
All pages respond well.
Close the website.
Leave it idle for 1 hour.
Open website, it is slow again, as if it's only been published

I can only assume it's something to do with the session, IIS or the app pool

In webforms I used to have tracing, I don't appear to have that in MVC and I don't know how I can debug such an issue.

MyDaftQuestions
  • 4,487
  • 17
  • 63
  • 120
  • That's actually the expected behavior, given that after a period of inactivity the application pool will recycle, to free up unused resources. Check the application pool Recycle settings to configure that duration. – Pablo Romeo Apr 20 '15 at 14:27
  • @PabloRomeo, are you saying that, if a website doesn't get hit every n seconds, that this will happen. When I say slow, I mean up to 10 seconds to load. I use MVC for a few sites, but the traffic is very low, a hundred visits a month. Naturally I'm getting complaints about speed issues, I don't think I can turn back and say it's expected :( – MyDaftQuestions Apr 20 '15 at 14:28
  • Correct, however, you can configure that time window. Also, you could try using the AutoStart feature, which would "warmp up" the application after deployment, and after a recycle. http://weblogs.asp.net/scottgu/auto-start-asp-net-applications-vs-2010-and-net-4-0-series – Pablo Romeo Apr 20 '15 at 14:32
  • @PabloRomeo, that seems, IMO, good enough to be an answer, if you're OK to move it as one? – MyDaftQuestions Apr 20 '15 at 14:34

1 Answers1

3

That's actually the expected behavior, given that after a period of inactivity the application pool will recycle, to free up unused resources. Check the application pool's Recycle settings to configure that duration.

If you also want additional control on what happens during recycling there are a few options:

  • IIS7.5 (ASP.NET 4) supports a feature called "AutoStart", which can warm up your site after deployment and after recycling.

  • IIS8 has additional support through the Application Initialization Module.

Pablo Romeo
  • 11,298
  • 2
  • 30
  • 58
  • It's a place for me to start learning how to deal with this slow-on-first-load issue. I find it a shame that Microsoft didn't put more focus on resolving this issue after this many versions of IIS. –  Jun 08 '15 at 04:44