1

I am relatively new to asp.net and IIS things, i have done many apps using other technologies, but never faced such a problem.

We have set up a lab on Azure, with all needed virtual machines, hosting the ASP.NET MVC 5.0 app on a machine (IIS 7), and another machine hosting SQL Server 2014 to host its database, we are using code first.

The issue is that when opening a page that lists records from a table from the database, it takes 15 seconds to do so, only for the first time when opening the website from chrome browser or any other browser, when continue navigating the website it takes no time at all. leaving the website for 10 minutes or so, and coming back, the issue happens again, and it takes 15 seconds again only once.

Digging deeper into the issue and after profiling of the performance, the most of the time taken is spend on the first time the app touches the database, for example, a very simple query:

model.Workflows.ToList();

Apparently connecting to the SQL server is taking the most of the time. 15 seconds for the first time is a lot of time to accept, I have never seen such a delay in any application.

the object graph is small its only 12 tables with very few records, even no records for some tables, for example, workflow table contains only 2 records. the relationships are complicated but not that much.

I have tried to connect without entity framework using SqlConnection class, and it takes 4 seconds for the first time also, it is much better but still there is something wrong.

Sampath
  • 63,341
  • 64
  • 307
  • 441
RaniDevpr
  • 410
  • 2
  • 13
  • 1
    Possible duplicate of [Entity Framework Code-First too slow at startup](http://stackoverflow.com/questions/28338613/entity-framework-code-first-too-slow-at-startup) – Red Sep 08 '16 at 09:48

1 Answers1

0

For those who still facing the same issue, I have tried many posted solutions with no luck at all, including the link provided by raderick and many other resources.

The only thing that worked for me, is by updating the whole Windows Server 2008 r2 (with IIS 7.5) to Windows Server 2012 r2 (with IIS 8.5). It looks like it is something related to IIS performance (maybe my testing lab) and not Entity framework.

There is a very useful option in IIS 8.5 within windows server 2012 r2, look into this links at point 7 (Application Pool Suspension), that did a huge jump in performance in my case.

http://www.infragistics.com/community/blogs/brijmishra/archive/2015/08/21/12-tips-to-increase-the-performance-of-asp-net-application-drastically-part-2.aspx

I know it is not a first option solution but it may help in some cases.

RaniDevpr
  • 410
  • 2
  • 13