1

Our web-application is on .net 1.1 and we have some legacy code that hangs-up IIS after every couple of days.

I was thinking about modifying machine.config settings to restart aspnet process after every couple of days, but the problem is it's going to kill existing sessions in process. Can I avoid it somehow.

Is there a better way to deal with this situation? right now client restarts IIS manually after every couple of days.

Thanks, A

Edit: If you have - un-serializable objects in your session, - cant work with sql-server

Then the good work around is to use "idleTimeout". It shuts down asp_net process if there is no activity on the server until the time specified. On the next request, it spawns asp_net process.

Ali
  • 309
  • 1
  • 5
  • 20
  • idle timeout in production sites is almost never a viable solution, since any production site should have monitoring that will hit the site frequently enough that it won't idle out. If you set your monitoring past the point of idle times you'll frequently get false positives of the site being down where the site is activating and failing to respond "timely". – Chris Marisic Aug 24 '11 at 12:57
  • I don't understand, idleTimeout shuts down the site and as soon as a new request hits the server it startsup asp_net process? Correct me if I am wrong – Ali Aug 24 '11 at 14:38
  • Suppose you set the idle time to 15 minutes of inactivity. You have a monitoring service that polls your site every 30 minutes. When the site has idled out, the monitoring service will be the callee that activates your site. The initial request that comprises the activation is signficiantly slower than a normal request (can easily exceed 1 minute) many monitors will automatically mark a website as failed if it exceeds X seconds to respond. This can lead to many emails in the middle of the night saying your service is down when it's really not. – Chris Marisic Aug 24 '11 at 14:43
  • Agreed, but because of our existing legacy application iis starts bloating with memory within a day or two (the code is well written). We are not planning to update it since we are already in the process of re-writing it. I guess for time-being it is the right approach. Right? – Ali Aug 24 '11 at 14:47
  • Using the idle timeout isn't a smart approach, however using the app pool to automatically recycle is an acceptable stopgap measure (much better than manually needing to recycle it AFTER it's broken) – Chris Marisic Aug 24 '11 at 14:48
  • How can I use app pool to free up / recycle resources ? – Ali Aug 24 '11 at 14:51
  • We cannot accept session-lost. – Ali Aug 24 '11 at 14:54

2 Answers2

2

I suggest two things:

  • Configure the application to use SQL Server to store session data - this allows the session data to survive a restart of the web application
  • Configure the application pool to recycle worker processes periodically: enter image description here

Of course, even better would be to update the web application to a recent framework version and fix at the same time the problem to prevent this from happening in the first place.

marapet
  • 54,856
  • 12
  • 170
  • 184
  • Coming to new .net FW is not an option for us (company strategy - We are in the process of re-writing). using sql-server is a good idea but clients don't have license for that. I guess I'll use idleTimeout to restart when there are no active sessions.. – Ali Aug 23 '11 at 20:02
  • A rewrite should do :-) it's just that .net 1.1 web sites are getting hard to maintain. I just mentioned it for completeness, you should be able to cover your needs by configuring app pool settings. – marapet Aug 23 '11 at 20:06
  • a "Company Strategy" of using .NET 1.1 in 2011 is called a failure. – Chris Marisic Aug 24 '11 at 12:58
  • @Chris I agree - but as the OP wrote, they're rewriting it completely. – marapet Aug 24 '11 at 14:04
  • @marapet thanks :) its a 8-9 year old application with no standards or best coding practices... – Ali Aug 24 '11 at 14:58
0

Do you actually store any type of data in Session? if you do, is it Serializable? If it is, just change the Web.config to use StateServer.

You just need to start ASP .NET State Service automatically by going to control panel--> administrative tools --> Services and setting up ASP .NET State Server to start automatically.

This will allow you to restart the aspnet_wp.exe process w/o losing session information; again, the only requirement is that the information you put in session is Serializable (which is likely the case or at least should be easy to do if your the code is not doing anything crazy)

Icarus
  • 63,293
  • 14
  • 100
  • 115
  • Thanks but I do have un-serializable objects in my session variable.. I think idleTimeout is the best work around for me since I cant re-write the application nor can I use sql-server or state-server... Thanks all anyway – Ali Aug 24 '11 at 12:43