Do IIS applications "go to sleep"?

R

Rob

In a previous thread, I was asking about setting up my global.aspx which
inherits System.Web.HttpApplication. This is where there are the event
handlers like:

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)

In this file I've got:

Private WithEvents ApplicationTimer As System.Timers.Timer ' used to
generate application events

and the associated:

Private Sub ApplicationTimer_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles ApplicationTimer.Elapsed

This works fine but for some reason, the timer stopped running after a
while. I had left the application idle on the web server. Do application
events continue to run forever even after all sessions on the webapp have
timed out/finished?

Cheers, Rob.
 
T

Teemu Keiski

Hi,

ASP.NEt application does have idleTimeOut in <processModel> element in
machine.config which specifies the time after worker process will shut down
if the app is idle. This setting applies in Windows 2000/XP/2003 (2003 only
in IIS 5.0 isolation mode).

If you use Windows Server 2003 in worker process isolation mode (not IIS 5.0
isolation mode), then application pool's settings apply.
 
M

Mark Fitzpatrick

IIS will dispose of the application eventually to improve performance and
release resources used by the application. Usually, this happens after the
last session times out, then application_end is called and the application
is removed. That's why when an ASP.Net app has been idle for a period of
time the first hit takes longer since it's recompiling and creating the new
application instance again.
 
C

Cowboy \(Gregory A. Beamer\)

One thing to remember is web applications are designed to be stateless. The
idea is there is a request from a client (generally a browser) and a
response from the server. To fake a session, a server cookie is set on the
client side. This type of cookie is not disabled when one disables client
cookies, so do not think of this as your typical cookie, except that both
send their information with every request. State is an illusion created by
using these session items (like a server cookie).

Now that you have that down, consider what happens to sessions that do not
need your timer when you extend a session timeout to five days. Everyone who
hits the application takes up memory for five days, or until the application
dies.

If you need a timer to run, you are better to set up a windows service that
will handle the timer. You can fire it off from your web application, if you
would like, but consider it a one way trip.

Short answer: You can configure this "timer" to stay up longer, but you may
end up with some bad effects.
 
R

Rob

Now that you have that down, consider what happens to sessions that do not
need your timer when you extend a session timeout to five days. Everyone
who hits the application takes up memory for five days, or until the
application dies.

The session doesn't need extending to five days, just need to ensure that
the application itself keeps running for longer than the last session
timeout (30 mins I think at the moment). The timer routine is actually used
to send an email summary of the user's action an hour after they last made
any changes. Therefore I just need the application to stay alive for a
couple of hours.
If you need a timer to run, you are better to set up a windows service
that will handle the timer. You can fire it off from your web application,
if you would like, but consider it a one way trip.

Appreciate that but it complicates the architecture of the application
considerably. I'll investigate idleTimeOut setting that was mentioned.

Cheers, Rob.
 
R

Rob

is removed. That's why when an ASP.Net app has been idle for a period of
time the first hit takes longer since it's recompiling and creating the
new application instance again.

I always wondered why that happened.

Cheers, Rob.
 
R

Rob

If you use Windows Server 2003 in worker process isolation mode (not IIS
5.0 isolation mode), then application pool's settings apply.

How do you check if it's running in worker process isolation mode?

And what is worker process isolation mode? :)

Thanks, Rob.
 
R

Rob

How do you check if it's running in worker process isolation mode?

It's okay - I found it on the website properties tag. I'm not running in IIS
5.0 isolation mode so I've changed the idle timeout on the application pool
from 20 minutes to 120 which should work a treat.

Cheers, Rob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top