What are optimal settings for Recycling of Application Pools in IIS7 in a shared environment?
you need to cater the settings to your needs, take into account the amount of memory you have and the peak times of usage for your site/web application.
Also take into account the memory usage of your site/web application as if there are memory leaks you might be recycling more often then you think.
Weigh up any leaks against the cost of recycling, as stated above you will lose state variables.
If you have a heavy traffic site, use long recycle schedule. If you have a low traffic site use shorter/default schedule to save memory.
I learned this from Al Zabir's blog: http://msmvps.com/blogs/omar/archive/2008/10/04/best-practices-for-creating-websites-in-iis-6-0.aspx
Daniel S. is right, your session variables get destroyed on recycle, so make sure you test this well or have good error protection/recovery when getting your session objects.
As a Hoster, you definitely want to recycle on Memory & Time, potentially Request limits and CPU. You want to be pretty aggressive about these limits, but make sure you publish them to your clients.
Memory - 512 for an x86 box, maybe 768. For x64, you can set this much higher depending on the number of hosts per server. You just have to be careful and watch your app pool recycle events on memory issues.
Time - We typically recycle at 1 am in the morning, plus or minus (first site 1:01, second 1:11, third 1:21, just so you don't have all recycling at the same time)
Request limit - 35,000 was the default for IIS6, but this number is quite arbitrary, and very dependant on the site in question. For small usage sites, the nightly recycle will hit long before you get 35k requests.
CPU - 95%/1 minute limit/KillW3WP, but use this carefully. My understanding of this is that if the CPU hits 95%+ over the 1 minute limit for this worker process, the worker process gets killed and is unable to restart for the remainder of the limit when Action is set to KillW3WP. You might want to try NoAction initially and just watch your event logs carefully.
Recycle Event Logs - You want to make sure you are logging app pool recycles for each event threshhold that you set - i.e. if you limit based off of requests limits, make sure that Request Limit logging is enabled.
One thing to remember is that you should set retail="true"
in the <deployment>
element in your machine.config:
<system.web>
<!--
<deployment
retail = "false" [true|false]
/>
-->
<deployment retail="true" />
</system.web>
Not setting this will allow a site to turn debugging on, which allows unlimited timeouts in requests - not exactly ideal for a hoster...
Tip: When you recycle your app, all your session variables are destroyed... so caution on this!
IMHO, keep the defaults.