I’m using EF 4 on my web site and have found a very disturbing problem – the first run load time is extremely slow. (about 20-30 seconds).
After the first run – it will work really fast.
What I mean by “first run” is a run after some long time of no activity (10 minutes or so).
So, if there is a lot of traffic, the site is working just fine. If there are slow days – the first one to come to the site after a long traffic break, will get a very bad experience.
Because the web site also exposes an API – the same happens there. The first to call it – will get a timeout on his side.
My DB is SQL Server 2008 R2.
Any ideas why this is happening? How to resolve?
Thanks!
Could be EF, but just as likely could be that your app pool is getting recycled on IIS or a combination.
If there are going to be slow periods of usage on your website, and you want each page to load fast for a visitor that happens along, in the past I have setup a timed job to hit my website at specific intervals (about 5 minutes worked for me), and that made sure that it was always ready to go when a visitor came along.
Very easy to do if you have access to a task scheduler.