0

This is similar to this question IIS 7.5 web application first request after app-pool recycle very slow and this question Slow first page load on asp.net site but it is not the same. At the point I am profiling, the application pool has already restarted. The answers on those questions are about keeping the application pool alive, which is not helpful in this case

After an application pool recycle, the first database call my ASP.NET application makes is extremely slow. Subsequent calls are extremely fast. This is to a local instance of SQL Server.

Here is a profile of after the application pool is recycled. The call takes 9.7 seconds. enter image description here

And here it is after the application pools have been up a while. The exact same call takes 12ms. enter image description here It's not a caching thing because if I ask the second call to pull back data for a different account it's still extremely fast.

It's really annoying while developing because every time I make a change and compile it recycles the app pool and then it takes far too long for the site to come up again.

What is going on here and is there any way to speed up the first call?

mhenry1384
  • 7,538
  • 5
  • 55
  • 74
  • 1
    Possible duplicate of [Slow first page load on asp.net site](https://stackoverflow.com/questions/2102609/slow-first-page-load-on-asp-net-site) – VDWWD Oct 17 '18 at 14:43
  • @VDWWD I don't agree because at the point I am profiling, the application pool has already started up. – mhenry1384 Oct 17 '18 at 16:38
  • 1
    Sounds like the first DB request is slow because it's opening a connection to the database, and subsequent requests are fast due to connection pooling. – mason Oct 17 '18 at 16:53
  • 1
    "It's not a caching thing because if I ask the second call to pull back data for a different account it's still extremely fast." Not necessarily. If you have a bad query plan and the first query requires a complete table scan, the cached pages would cover the other accounts. – David Browne - Microsoft Oct 17 '18 at 17:39

0 Answers0