Whether you host in-house or with a managed Windows hosting provider, if you self-administer a web server it is good to know that by default IIS7 sets application pools to “time-out” after 20 minutes of inactivity. So if you don’t have any visitors to your site within 20 minutes, the application pool will shut down – freeing up those system resources. Then the next time a request comes into the site IIS7 will automatically restart the application pool and serve up the requested pages.
This is a great way to preserve resources since every running application pool does place a certain amount of overhead on the system. But, it also means that the first request – the one that causes the application pool to restart – is very slow. It is slow because the process literally needs to start, then load the required assemblies (like .NET) then load the requested pages. Depending on the size and complexity of your application, this might just be a couple of seconds or it might take 30+ seconds (during which time a user would likely give up and move on to a different site).
If you want to extend the length of the time-out setting, just change it from the default of 20 to however many minutes you want. You can also adjust the setting to 0 (zero) which effectively disables the timeout so that the application pool will never shut down due to being idle.
To make this change, open Server Manager; Expand the Roles node; Expand the Web Server (IIS) node. Then click on the Web Server (IIS) node; Expand the node with your local server name; and click on the Application Pools icon. You’ll then see a list of the application pools that are defined on your server. In the right-hand pane you’ll see an option for Advanced Settings – click that.
Once you see the Advanced Settings dialog box just look for the Idle Time-out (minutes) property; click where the default “20” is, and change it to whatever value you prefer.
This is just one of many settings that can impact the performance, uptime, and functioning of your web site. If you don’t have the time or interest in learning and maintaining the various settings for a secure high-performing web server, you might want to consider a fully managed windows hosting solution and let a trained and experienced administrator take care of the work for you. That can both alleviate a ton of stress and also enhance the security, performance, and uptime for your web application.
Happy hosting!
Brad on Google+
owesome blog, keep it up :)
Will the asp.net sessions be cleared once the Idle timeout is reached? This seems to be what I am experiencing.
Yes. To avoid that you need at least one visitor every 20 minutes, or you need to adjust the time-out threshold (perhaps setting it to 0 if you don’t want it to time-out).
so if i set it to 0, will my server run slower and slower because of it use more resourse?
It depends on your application. If the consumed resources of all the combined sites running on your server consume less than ~80% of the server resources, you’re likely fine.
Really very good information. I was searching in many site but i didt get any useful information. Atlast i got it.
One question: My application IIS ideal time out = 20 (default value) and session time out is 10 hours. The user is doing some thing and he is ideal for one hour. again he is doing some operation. that time my session values are gone. Which means, will it clear the session of the particular user if it is not being used by more than 20 mins.
If the application pool recycles, all session variables are lost.
Does this timeout shutdown the application pool or just the worker process? So if you had multiple worker processes (applications) running in the same application pool, would it restart the whole pool? Technet seems to indicate here that it just kills the process, not the whole pool. Thoughts?
99%+ of sites run with a single worker process (for very good reason), in which case a shut down of the app pool and the worker process are the same thing.
For web gardens (multiple worker processes) I believe it will shut them down one at a time if idle, so once each is idle then essentially the app pool shuts down. Because of the way that traffic is balanced with a web garden though you wouldn’t likely see consistent traffic to one process and not the other – so both would go idle around the same time.
Very nicely explained in [gasp!] plain understandable English.
I have recently had to make sense of this IIS timeout malarkey for a work project in which I send regular pings via a jQuery command in order to keep IIS sessions alive indefinitely.
Having this information has helped me understand and debug the thing much better.
I am facing an issue with IIS7.
When i am hosting an asp.net application on IIS6, my crystal report along with its toolbar is working fine. But when the same application is hosted in IIS7, the crystal report is working but its toolbar is not, as a result users are not able to take print or export the report document data. Will be of great helpful if you can post a solution along with screen shots. Thanks !!!
But if the Session state mode is “in-proc” and Session Timeout is 60 mins, then idle shutdown of 20 mins will affect your session too since no worker process = no session. Am I correct?
Yes, that is correct.
If your session is set to time out in 60 mins and your worker process dies within 20 mins then that means that your session dies in 20 mins too right?
Correct.
Thank you Salman & Brad. I have got the solution. I have one more issue. I have hosted an application developed in VS 2008 and crystal report version 10.5.3700. when i am hosting this application on IIS6, everything is working fine. But when i host the application in IIS7, the crystal report toolbar is not working. I mean both print and export functions are not working and asking for “Map Request Handler” At present this application is hosted on Windows Server 2008 Std edition
Guys,
Thanks a lot. I got the solution for both my issues.
Here’s a quick question… does anyone know the expected behaviour regarding having an idle timeout of 0, and recycling the app pool? ie: will the app pool actually restart?
So to flesh it out further, say I have expensive startup code in my Application Start (global.asax) (which obviously we do hence looking at avoiding the idle timeout… anyway).
So now I set my idle timeout to 0, and the app pool just keeps running. But for the sake of stability and memory, all those things that were specifically why Microsoft introduced app pool recycling, I set the app pool to recycle ever 4 hours for example. When the app pool gets recycled, will my app actually start up again (run the application start event), or do I have to wait for the first request?
Any ideas?
Thanks!
The app pool will restart upon the first request to the application.
BTW – you don’t need to set recycling unless you are running low on resources. We host thousands of sites at orcsweb.com and very few people have recycling enabled on their sites.
Hi Brad,we are facing some strange problem since last few weeks. We have a site which is developed for our Australian clients. And it is temporally hosted in a local IIS server. The problem they reporting to us is a session time out occurs in one minute two minute time since they become idle. But here we tested it and we never experienced any thing like that. What will be the possible reasons for these differences in session time out? Will time out have any relations with regional settings?
No, regional settings do not impact the time-out. Did you check the settings in IIS to compare them?
Hi Brad, thanks for the reply. I didn’t check the IIS settings, i will check it and will reply you the details.
But why we wondering is in case if there is any issues exists with ISS settings, we also should have faced that same problem here. But its only them reporting this issue.
That’s why we confused with from where to start and what will be the possible causes for these…
Thanks..
HI brad, some how the problem got solved. :smile:
Thanks again for you time and support…
Hi!
I have an app pool here that I want to be available all the time. But setting the timeout to zero did not help, the app pool still goes to sleep after some time.
What am I doing wrong??? :sad:
Are you sure it is going to sleep? Perhaps it is set to auto-recycle; which you can also disable.
Thanks for the fast reply!!!
Yes, I’m sure. Well, quite… ;-)
If it is auto-recycle, I’ll try to find and disable that, too.
Another problem that I have here is, that the app pool recycles (ungracefully) when I add an application to it. This disturbs the currently logged in users.
Is there a way to prevent that?
Are you updating the web.config file? I can’t think of anything else that would normally (without some sort of issue) cause a recycle of the application.
Well, the web.config file is probably updated when the app is added to the pool.
Rotating recycling is “off” right now. Would it help to set it “on” to avoid disturbing the other applications? I would think so…
Hi Brad, we have a peculiar situation where seems like the application start does not seems to be triggered once after the idle timeout has reached and when a first request is fired. We are forced to involve the support groups and recycle IIS. As an interim measure we have increased the idle timeout to be 24 hours, but that does not seem to help either.
Is there any other settings in IIS that we will need to look into?
Any thoughts/insights will be of great help.
Thanks
Suresh
Are you SURE its the idle timeout that is causing the issue? Your support team should be able to check the logs to confirm. This sounds like an issue unrelated to the timeout and instead something causing the application pool to hang.
When the user logs off(session timeout) from the application, the allocated memory to the user is freed up. But the does the app still hold some memory till the idle timeout happens??(Considering the session timeout occurs sooner than the idle timeout)
Need to know the differences b/w idle timeout and session timeout.. Thanks in advance
Session timeout will free a small amount of resources that were allocated to just that visitor; idle timeout will free ALL resources allocated to the site – the .NET assemblies and everything. Because of that, the first visit to the site after an idle timeout will cause the site to reload and take longer to display for that first visitor.
Hi
is there any other reasons that application pool restart ?
because when i set the Idle timeout for a long time and the sesion timeout in the site also set for long time ,But when i active in the site ,all of the session recycle suddenly!
why ??
My application IIS ideal time out is set to 20 mins and session time out is also 20 mins. The user is doing some operation (like filling the details in a large form for than 30 mins). After 20 mins the session gets expired and the user is redirected to a custom message page. Now we want to increase the session timeout to 30 mins. Does it mean we also need to increase the idle timeout property for application pool to 30 mins assuming a case where a single user would be using the application.
I would make sure the idle timeout is longer than the session timeout.
I have set the idle time out 0 to disables the timeout. But it did not work me at all. So that I have created a windows scheduler and calling my application pool every 10 minutes interval. But this is works for me.
Why idle time out 0 did not work me ? Any other settings I need to change ?
Are you sure it is timing-out? Do you see a note in the Event Log confirming that? If not, perhaps something else is causing the application pool to recycle.
Brad- I recently enabled the app pool recycle condition at specific time. Is this because of that ?
Yes. That’s causing the recycle rather than a timeout.