110

In IIS there are two areas (well, more than two) where recycling can occur:

  1. Under the "Process Model" section → "Idle Timeout" (default 20 minutes)

and

  1. Under the "Recycle" section → "Regular Time Interval" (default 1740 minutes)

My questions are:

  1. What are the differences between the two methods?
  2. What are the negative implications of settings them to 0?
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Ricky
  • 2,850
  • 5
  • 28
  • 41

4 Answers4

111

Idle Timeout is if no action has been asked from your web app, it the process will drop and release everything from memory

Recycle is a forced action on the application where your processed is closed and started again, for memory leaking purposes and system health

The negative impact of both is usually the use of your Session and Application state is lost if you mess with Recycle to a faster time.(logged in users etc will be logged out, if they where about to "check out" all would have been lost" that's why recycle is at such a large time out value, idle timeout doesn't matter because nobody is logged in anyway and figure 20 minutes an no action they are not still "shopping"

The positive would be get rid of the idle time out as your website will respond faster on its "first" response if its not a highly active site where a user would have to wait for it to load if you have 1 user every 20 minutes lets say. So a website that get his less then 1 time in 20 minutes actually you would want to increase this value as the website has to load up again from scratch for each user. but if you set this to 0 over a long time, any memory leaks in code could over a certain amount of time, entirely take over the server.

MichaelEvanchik
  • 1,748
  • 1
  • 13
  • 23
  • Thanks! That makes sense. My main dilemma is that the "first load" is taking very long. I thought that if I set both of these to 0 then I can circumvent that. However, the issue of memory leak is a problem. Is there a way to "recycle" but then "force" a request so that the "first time access" is over and done with immediately after the recycle? Or maybe schedule the recycle at 2am, and then schedule a "first time access" at 2:30am? Is there a way in IIS to do that? – Ricky Nov 14 '13 at 19:58
  • @Ricky I was getting the first-hit-takes-ages problem too. You need to set your application pool startMode to be AlwaysRunning: http://msdn.microsoft.com/en-us/library/ee677285%28v=azure.10%29.aspx – Steve Hibbert May 13 '14 at 17:27
  • This was useful to me too: https://www.simple-talk.com/blogs/2013/03/05/speeding-up-your-application-with-the-iis-auto-start-feature/ – Steve Hibbert May 13 '14 at 17:27
  • 3
    @Silvermind - If the session is stored in process it wouldn't be copied upon recycle. See [here](http://stackoverflow.com/a/4278040/1057791). – BornToCode Jun 26 '16 at 08:51
  • @Michael - You mentioned _Idle Timeout is if no action has been asked from your web app, it the process will drop and release everything from memory_. Does this mean that if my application uses `IMemoryCache` to store data in the server's memory it will also get deleted if the gets into an idle state? – Josh Monreal Nov 19 '21 at 14:11
33

From here:

One way to conserve system resources is to configure idle time-out settings for the worker processes in an application pool. When these settings are configured, a worker process will shut down after a specified period of inactivity. The default value for idle time-out is 20 minutes.

Also check Why is the IIS default app pool recycle set to 1740 minutes?

If you have a just a few sites on your server and you want them to always load fast then set this to zero. Otherwise, when you have 20 minutes without any traffic then the app pool will terminate so that it can start up again on the next visit. The problem is that the first visit to an app pool needs to create a new w3wp.exe worker process which is slow because the app pool needs to be created, ASP.NET or another framework needs to be loaded, and then your application needs to be loaded. That can take a few seconds. Therefore I set that to 0 every chance I have, unless it’s for a server that hosts a lot of sites that don’t always need to be running.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
8

IIS now has

Idle Time-out Action : Suspend setting

Suspending is just freezes the process and it is much more efficient than the destroying the process.

nPcomp
  • 8,637
  • 2
  • 54
  • 49
  • But I think the problem about suspending a process is that the memory used is not removed and freed. However terminating a process does it so it avoids memory leaks, etc. – Willy Nov 13 '20 at 09:04
1

I have inherited a desktop app that makes calls to a series of Web Services on IIS. The web services (also) have to be able to run timed processes, independently (without having the client on). Hence they all have timers. The web service timers were shutting down (memory leak?) so we set the Idle time out to 0 and timers stay on.

DaniDev
  • 2,471
  • 2
  • 22
  • 29