Tuesday, May 19, 2009

How to avoid IISREST from using on servers

Why should I avoid to use IISRESET?
In short, iisreset is bad. Running it on production servers is especially bad. Restarting or stopping IIS, or rebooting your Web server, is a severe action. When you restart the Internet service, all sessions connected to your Web server (including Internet, FTP, SMTP, and NNTP) are dropped. Any data held in Web applications is lost. All Internet sites are unavailable until Internet services are restarted. For this reason, you should avoid restarting, stopping, or rebooting your server if at all possible.

Known problems on Exchange Servers after IISRESET
Running IISRESET on Exchange Server will not affect to start back SMTP, POP3, MS Exchange Routine Engine services.

How to restart approporiate Web Site
You can restart the site in IIS manager or by editing web.config file under site's root directory - open it in notepad, add a space, remove the space, and save. The change to the file timestamp will cause the site to reload. In both cases workin process (application pool) will continue working.

How to restart approporiate Application Pool

Each Application Pool is completely separated from other App Pools by running in its own process called w3wp.exe (in IIS5 aspnet_wp.exe). Only problem if server has multiple sites under each application pool on staging and production servers. It could be done because it keeps the overheads to be minimal (each W3WP.exe process needs circa 25MB to run). But of course it increases the vulnerability even whether ASP.NET hosting server has medium trust level, because it allows to write data everywhere under the same Application Pool. But this is another threat.

IIS6

First of all you need to identify which application pool is associated with which w3wp.exe process. Open CMD, navigate system32 directory and type:

C:\Windows\System32> cscript iisapp.vbs

You will get a table like

W3WP.exe PID: 788   AppPoolId: N24
W3WP.exe PID: 4836   AppPoolId: Irbi
W3WP.exe PID: 2668   AppPoolId: BV
W3WP.exe PID: 2200   AppPoolId: Heise
W3WP.exe PID: 1716   AppPoolId: Roedl


Now you need to kill approporiate process. It will start again automatically after the next web site request. So run:

C:\Windows\System32> taskkill /PID 788

IIS7

Here steps are more easilly done. Get the needed name of the approporiate Application Pool in the IIS manager. Go to %windir%\system32\inetsrv and recycle an application pool by running

C:\Windows\System32\inetsrv> appcmd recycle apppool "apppool_name"

How to disalbe IISRESET from the command line

At a command prompt, type iisreset /disable, and press ENTER. This command disables IIS and prevents all iisreset calls from executing.

More links:
Restarting IIS (IIS 6.0)
What does iisreset do in IIS 7.0?

No comments:

Post a Comment