Friday, April 03, 2009

Keeping Web Sites Alive (IIS/ASP.Net)

IIS recycles app pools periodically and the first request which comes after a recycle takes too much time to process because the whole app needs to be loaded and compiled. By default the idle time is 20 minutes.

1. Configure App Pool to recycle when you need it to
2. Setup a ping service which will act as the first request to reach the web site after a recycle

Method & Details:

1. IIS App Pools
IIS App Pool concept is a very useful thing in keeping web sites in same server seperate from eachother. App Pool recycling is also an important activity which cleans up left overs from your application runings.

But default IIS App Pool recycle options are not suitable for a highly responsive site. It can recycle
  • Every n minutes
  • After m requests
  • At specific times of the day
  • If consuming M amount of virtual or physical memory
  • If idle for p mins
  • If kernel request queue (where http requests are kept before dispatching to IIS) has more than x requests
You have to change the default settings to suit your requirement while making sure that recycling actually happens as well. I recommend using the specific time of day approach to force a recycle at a low traffic time.

2. Keep Alive Services
A Keep Alive Service will send a dummy request to your site just to make sure that it won't go to sleep (recycle). One other important attribute of a keep alive request is that it should not make the current logged in user count to go up. So typically Keep Alive services will send a request to a 'KeepAlive' web page of the site which is specifically made so that the user statistics are not screwed up. Following keep alive page will show the current time,

<head><meta http-equiv="refresh" content="300"></head>
<p>Current Time Is : </p><%=now%>

There are 2 kinds of Keep Alive services
  1. Web based services -,
  2. Standalone Applications - Siteup by Xequte
The standalone applications is useful but it has a heavy dependancy on the machine that you install it. If the machine is down or the application is shutdown by someone you have a risk. I recommend the usage of web based service (for a nominal fee). They provide much more features as well as releasing you the burden of keeping the keep alive service alive.
Post a Comment