IIS 5 进程回收工具 (英文)是一个非常有用的工具,有了它,您可以将 IIS 5 配置为根据 http gets 的数量、时间、内存消耗量以及其他参数重新启动。这个工具是在发布 ASP.net 前开发的,因此它根本无法识别 aspnet_wp.exe 这个在 IIS 5 服务器上运行 ASP.net 应用程序的文件。然而,当使用进程回收工具、IISRESET 以及任何其他方法回收 IIS 时,ASP.net 也会重新启动;不过您还可以使用内置在 ASP.net 中的配置元素,单独回收 ASP.net。
这可以通过 ASP.net 的 web.config 文件中的进程配置设置来实现。默认情况下,web.config 位于 %systemroot%\Microsoft.Net\Framework\v<version number>\CONFIG 目录中。它是一个 XML 文件,您可以使用记事本等文本编辑器来打开和编辑它。打开这个文件并搜索“processmodel"。这将定位到进程模式配置部分,其中包含以下具有注释内容的节:
<!--
processModel Attributes: enable="[true|false]" - Enable process Model
timeout="[Infinite | HH:MM:SS]" - Total life of process, once expired process is shutdown and a new process is created
idleTimeout="[Infinite | HH:MM:SS]" - Total idle life of process, once expired process is automatically shutdown
shutdownTimeout="[Infinite | HH:MM:SS]" - Time process is given to shutdown gracefully before being killed
requestLimit="[Infinite | number]" - Total number of requests to serve before process is shutdown
requestQueueLimit="[Infinite | number]" - Number of queued requests allowed before process is shutdown
restartQueueLimit="[Infinite | number]" - Number of requests kept in queue while process is restarting
memoryLimit="[number]" - Represents percentage of physical memory process is allowed to use before process is recycled
webGarden="[true|false]" - Determines whether a process should be affinitized with a particular CPU
cpuMask="[bit mask]" - Controls number of available CPUs available for ASP.NET processes (webGarden must be set to true)
userName="[user]" - Windows user to run the process as.
Special users: "SYSTEM": run as localsystem (high privilege admin) account.v "machine": run as low privilege user account named "ASPNET".
Other users: If domain is not specified, current machine name is assumed to be the domain name.
password="[AutoGenerate | password]" - Password of windows user. For special users (SYSTEM and machine), specify "AutoGenerate".
logLevel="[All|None|Errors]" - Event types logged to the event log
clientConnectedCheck="[HH:MM:SS]" - Time a request is left in the queue before ASP.NET does a client connected check
comAuthenticationLevel="[Default|None|Connect|Call|Pkt|PktIntegrity|PktPrivacy]" - Level of authentication for DCOM security
comImpersonationLevel="[Default|Anonymous|Identify|Impersonate|Delegate]" - Authentication level for COM security
responseDeadlockInterval="[Infinite | HH:MM:SS]" - For deadlock detection, timeout for responses when there are executing requests.
responseRestartDeadlockInterval="[Infinite | HH:MM:SS]" - Time to wait between restarting WPs due to responseDeadlockInterval
maxWorkerThreads="[number]" - Maximum number of worker threads per CPU in the thread pool
maxIoThreads="[number]" - Maximum number of IO threads per CPU in the thread pool
serverErrorMessageFile="[filename]" - Customization for "Server Unavailable" message
When ASP.NET is running under IIS 6 in native mode, the IIS 6 process model is used and settings in this section are ignored.
Please use the IIS administrative UI to configure things like process identity and cycling for the IIS worker process for the desired application.
-->
注意,可以为上面的“timeout"变量设置一个单位为时、分、秒的值,这个值指定了 aspnet_wp.exe 进程的生存时间。当 ASP.net 启动 aspnet_wp.exe(它在首次启动时调用一个需要 ASP.net 的页面)时,该计时器开始计时。当 asnet_wp.exe 进程“活着"的时间等于超时值时,将会被回收。
尽管这不同于设定一个日期和时间来回收 ASP.net 进程,但是这可以实现定期回收,并且可以保证应用程序的正常运行。另外,您可以控制这个回收操作的其他方面,例如在工作进程不再使用时关闭它(从而实现在非高峰期执行回收操作)。