How to create an immortal web app?

D

daykirby

Sorry if this is a crosspost - I think I put this in the wrong group
before.

I have an asp.net app that takes a few minutes to start on the server
site (unavoidable) but once running it processes requests and serves
data to the client quickly.

Once started, I hold the app in memory using Application variables.
This is working great, and after the first session starts, subsequent
sessions have access to the (already started) app and the requests get
processed quickly.

My problem is that the Application variables seem to have dissapeared
when I get to work in the morning (I actually don't know what time the
app stops, but during my workday it doesn't happen so I think the
Application variables are persisting for a few hours anyway).

I'm having trouble finding documentation on the lifecycle of
Application variables, the Application_End event, etc.

Can (and should) I keep my app alive indefinitely? Is this something I
set in global.asax (like I do with Session variables), should I look
for some IIS settings? Should I take a different strategy maybe and
restart the app on a schedule?

Thanks!
 
D

Darren Kopp

Check the IIS settings for the application pool that the application is
running in (in IIS6 only, go to the app pool, right click, properties).
You can modify the timeout values and recycling values so that your
application won't recycle itself. I would think it would be a good
idea to restart the app every now and then.

HTH,
Darren Kopp
http://blog.secudocs.com/
 
G

Guest

(e-mail address removed) wrote in @p10g2000cwp.googlegroups.com:
Can (and should) I keep my app alive indefinitely? Is this something I
set in global.asax (like I do with Session variables), should I look
for some IIS settings? Should I take a different strategy maybe and
restart the app on a schedule?

Paul Wilson has an example:

http://authors.aspalliance.com/paulwilson/articles/?id=12

But if you need your app to stay alive, I suggest a service - or use a
database to store our variables.
 
K

Kevin Spencer

An ASP.Net application times out, just as the Session times out. The
difference is that Session times out (default) 20 minutes after the last
request from a given client. The Application times out (default) 20 minutes
after the last request from *any* client.

It is important to understand that no in-memory data is safe from
application re-starts, as even if the Application did not time out, there
would be times when the server would need to be re-started for any number of
reasons (such as a power failure). You need to handle these situations
gracefully in any application.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer

Presuming that God is "only an idea" -
Ideas exist.
Therefore, God exists.
 
D

daykirby

Thanks for the info/advice, everybody!

I don't have much experience with Web Servcies yet, but wouldn't I have
the same problem - the web service would take a while to initialize the
first time and would need to be restarted regularly? Obviously I have
some research to do...

Kevin makes a good point that there are going to be unavoidable cases
when the app needs to be restarted. This makes me think that I'd love
to have a way that it restarts itself, without a request from a client.
Can anyone point me in the right direction to learn how to do this?

Thanks again,
Day
 
D

Darren Kopp

Well, at the easiest end of the spectrum, you could just make a
scheduled task that runs iisreset, if that is possible for you to reset
the entire iis process. If that's not possible, you could probably
make a scheduled task that runs a batch file or executable that
restarts the individual app through IIS (sorry, I don't know what that
command would be).

HTH,
Darren Kopp
http://blog.secudocs.com/
 

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

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top