Login :: Register
General Topics
HostedbyMaximumASP170x35
2005 IIS MVPs
Other IIS Sites
  Demonstration of Application Pool recycling side affects on IIS 6. 

In this demonstration we have configured a web site to use a specific custom application pool which has been configured to recycle after 5 requests as a demonstration to show the potential of session state loss while an application is running.

By the use of this demonstration I am attempting to show you that process recycling can have an apparent random loss of session state.

The default recycling settings for an application pool is to recycle every 1740 minutes which is 29 hours.

This means a user could make a request at 28 hours and 59 minutes after the first request to the web server and one minute later the application pool is recycled loosing their session state. Now you may not just have one user there may be 500 or 1000 users on your site.

Session state in ASP is handled In-Process to the application pool and unless you use a 3rd party session management object you will see these affects. ASP.NET is also vulnerable to this loss of session state if you have the session state for the application set to InProc in web.config. If you use the session state server or a SQL Server then you will not see the effects described here.

If you add the following code to a .ASP file each time you refresh this web page you will see when it was last requested and the number of times it has run. The count and the last time run are simply stored in ASP Session variables.

After the fifth request the process is recycled as we have configured it to. The affect of this recycling is that the ASP Session state is lost.

Now this is not a bug in IIS or in the way Application Pools work it is simply something that you should be awear of.

I have been to a few Microsoft presentations of IIS6 and although they mention the virtues of Application Process Recycling they have never mentioned this loss of session state which is something you should know exists.

<HTML>
<body>
<%
    if (Session("RunTimes") & "" = "") then
        Session("LastRun") = "Never"
        Session("RunTimes") = 1
    else
       Session("LastRun") = now
       Session("RunTimes") = Session("RunTimes") + 1
end if
%>
This web application was last requested <%=Session("LastRun")%>
This web application has been run <%=Session("RunTimes") %> times

</body>
</HTML>


Results of running the ASP Code above

This web application was last requested Never
This web application has been run 1 times.


This web application was last requested 6/13/2003 7:40:14 AM
This web application has been run 2 times.
This web application was last requested 6/13/2003 7:40:19 AM
This web application has been run 3 times.
This web application was last requested 6/13/2003 7:40:26 AM
This web application has been run 4 times.
This web application was last requested 6/13/2003 7:40:30 AM
This web application has been run 5 times.
This web application was last requested Never
This web application has been run 1 times.

 This site and its contents are Copyright 1999-2004 by IISFAQ Microsoft Corporation in no way endorses or is affiliated with IISFAQ