No Web server is perfect. High volume Web sites that perform complex tasks tend to go down occasionally regardless of what platform and server you are running. IIS has had its problems of major instabilities especially prior to the release of NT SP5, but the problem is just as common on Unix/Sun platforms especially for servers running heavy duty server applications. For this reason Web Connection ships with Web Monitor which is a utility that allows you to monitor your Web site and take action when the Web server goes down. This document deals with IIS specifically, but you can apply the concepts to other NT Web servers like Apache or Website.
I've set up Web Monitor to check for IIS dying and if it does automatically killing any running COM instances of my WC application (if they're still running) and then restarting the Web server.
To do this I set up as follows:
- Web Monitor to monitor a static HTML page on my Web site (wwPricing.htm). I check for a specific string in the request output in this case West Wind Technologies. The interval is set to 60 seconds.
- On the Site Down page I set up an email to be sent to me with West Wind is Down/West Wind is back up for the notification messages.
- I also set up an EXE file to run and I run WebRestart.bat which looks as follows:
Windows 2000
IISRESET
IIS 5 ships with this handy utility which resets the the IIS and all of its surrogates (HTTP,FTP, SMTP etc. if configured) in one fell swoop. In fact it does so automatically if this utility detects that IIS crashed. If IIS gets hung badly you may still want utilize the KILL utility described below as the Web service may not be able to shut down (rare).
Windows NT
KILL INETINFO
KILL WC3COMDEMO
DIR \winnt\system32
NET START IISADMIN
NET START W3SVC
NET START 'FTP Publishing Service'
This uses the NT Resource Kit KILL utility which allows terminating a process with a hard reset (which is often required in order to get IIS to unload). First Inetinfo kills the Web server and then I also kill any still running instances of my Web Connection COM servers. The DIR line is used to waste some time on the server - NET START can't restart the Web server until it's fully unloaded which can take a couple of seconds even with KILL. The DIR delays for a few seconds. Then all the services are started back up. The Web Connection COM servers will restart automatically when the Web site is hit for the first time.
If you follow these steps any IIS crashes will be minimized to a maximum of a minute of downtime.
Mind you this doesn't happen frequently in my installation of NT 4.0 and SP5, but was occurring quite frequently with SP4 - about once a week. It's now down to about once a month. The question invariably comes up - is Web Connection crashing IIS? The answer is: Probably not. On installations that run pure Web Connection applications the Web server is extremely stable. Installation that make heavy use of ASP on the other hand have frequent crashing problems, especially if the ASP pages use COM components or advanced ADO features.