Last post Sep 10, 2019 12:03 PM by cenk1536
Sep 05, 2019 01:15 PM|cenk1536|LINK
I have an asp.net web API. When my service is called at the very first time or after 1-2 hour break, reponse takes much longer. But after the initial response or not having breaks, my service responses very quickly. How can I solve this? Is there any setting
in the IIS or in the entity framework? I think on the first query EF compiles the model that's why it takes so much.
Sep 05, 2019 10:36 PM|PaulTheSmith|LINK
I suspect it is nothing to do with the query.
Are you using a shared hosting facility? I had this problem on my GoDaddy web site. The problem seemed to be that the hosting process was put to sleep (hibernated, run down, exited, whatever) if inactive for a (short) period of time, the database server
also seems to be disconnected some how. The application pool is recycled approximately every 24 hours which also puts me into this "start the web server process, start the database server" state. I chose not to investigate too deeply
but rather to work around the problem and move on to soling business problems.
My solution was to add a loop which runs in the background that does a very simple request to the server (which executes a query) every 2 minutes. Crude, but effective.
Sep 06, 2019 01:49 AM|bruce (sqlwork.com)|LINK
Sep 06, 2019 06:03 AM|cenk1536|LINK
Can it be due to EF compiles the model that's why it takes so much?
Sep 06, 2019 06:47 AM|cenk1536|LINK
In EF section I am suggested to use this; because on the first query EF compiles the model that's why it takes so much.
public class MyDbConfiguration : DbConfiguration
public MyDbConfiguration() : base()
var path = Path.GetDirectoryName(this.GetType().Assembly.Location);
Sep 06, 2019 05:42 PM|cenk1536|LINK
I tried that code but nothing changed, still first response takes more time.
Sep 07, 2019 08:36 AM|cenk1536|LINK
I also changed idetimeout=0, preload=true but still takes time. What is missing?
Sep 09, 2019 01:46 AM|Nan Yu|LINK
An application will always take a little extra time to load as the application domain starts up. You can try IIS level setting like install the IIS feature `Application Initialization`.
Refer to below links for more details :
Sep 09, 2019 08:14 AM|cenk1536|LINK
I already done those.
Sep 10, 2019 11:44 AM|PatriceSc|LINK
Could it be rather caused by having the IIS starting. You could change https://aspnetfaq.com/iis7-application-pool-idle-time-out-settings/ to keep the site up and running longer
(the default is 20 minutes after the last activity)..
Sep 10, 2019 12:03 PM|cenk1536|LINK
I have already changed the time-out = 0. I will send a request after recycling with a scheduled task on the server. Hope it will make the trick.