22

I'm writing an ASP.NET Web API application hosted on IIS7 (no special configuration).

My problem is that for each first request (on a new machine/new browser/after a while...) there is a long delay - even on requests that return constants!

I've read about "warming up" scripts but it's not the issue here. It seems like the web server is trying to create a session and it takes very long time. Any suggestions?

EDIT

I think the delay is caused by worker-process creation for each new session. Now the question is why is it so slow, and why doesn't the web server reuse living worker-processes to serve requests?

I have configured the application pool to limit worker processes to 5 with no timeout (set to 0). This caused the first five sessions to be slow on first requests (which I can live with) and now the worker processes are alive. But surprisingly, from time to time, the request is slow again!

3
  • What exactly happens? Is this first request so slow after some time, from new browser window, from new machine, with all those conditions or with any of them? Commented Nov 24, 2013 at 4:30
  • any of them. on my own PC it doesn't happen so I guess it's an IIS configuration issue Commented Nov 24, 2013 at 6:37
  • every day in CRM and SharePoint we sense very delays on starting web applications is this useful for SharePoint sites ??? Commented Feb 9, 2015 at 13:02

2 Answers 2

15

If you are using Windows Server 2008 R2 you could configure the Auto-Start feature on the Application Pool. Also in the properties of the application pool you should disable it from being recycled at regular intervals. Bear in mind though that while this will limit the slowness, the application pool could still be recycled by IIS. With the Auto-Start feature it will be loaded again automatically in memory, but the code in your Application_Start will be executed on the next request. So you could still observe some slowness.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you. It's much better now. I still have some performance problems after not accessing the service for a while, but on a static operation it return always quick (others involve EF).
Any solution for the case when IIS 6.0 is still in use? :( AFAIK this feature is available only in the IIS version 7.5 or higher.
@TomasWalek, no, I am afraid there isn't. That was one of the main reasons why I upgraded.
is this useful for SharePoint sites ??? because we have many delays in first request everyday
0

Another cause can be https. Our site can run with and without https. The delay at the first page (5 to 15 seconds) occurs only with using https. This post explains the issue with https and the fix:

https issue by the MCS team

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.