Friday, March 3, 2006

The case of the forgetful web application.


Q: Mr. Carroll,  (See that "Mr"... makes you feel old doesn't it!)  Hope you remember me; I was in your IIS class a couple of weeks ago.  I have a question if you could spare some time.  We talked about setting memory restrictions to recycle application pools.  Our web applications die every few days and I have determined it is the w3wp.exe that is the problem.  It's memory usage grows until it crashes but it crashes at different amounts of memory used.  So my question is if I set the memory restriction a low amount or a short time period to recycle will this cause performance to decline on our web apps?  Hope you can help... and great class by the way!  And see, your teachings are already paying off for your students!
Thanks,
Kerry

A: Hey Kerry. Thanks for the compliment; I'm glad you enjoyed the class.
The results of how you adjust the memory usage settings will differ from web-app to web-app. The way to get the best result is to change the settings and benchmark the results. It may take four or five times to optimize the settings for your particular app, so make sure to log the results each time.
Another thing to consider is, if the application was written locally (that is to say it is not an off-the-shelf product) you should talk to the programmer who wrote it and make sure that he/she hasn't left any memory leaks in the application. (When I say "locally" that also includes anyone at a higher echelon of your organization. Just because John Doe is the head programmer of your corporate headquarters doesn't mean that he doesn't make mistakes.) To ensure this, have the programmer ensure that they are destroying any objects that they create, like this:
In this example you have a bit of ASP code using VBScript as its language. In VBScript, Nothing is a keyword that is used to remove objects from memory or "destroy" them.
Once you've gone through the code and adjusted the memory settings of your application in IIS, you can always gain a little more memory capacity by having your web-app reduce its caffine intake... at least, that's what my wife says.