2013年4月7日

解決網頁回應『Server is too busy』

WEB Server版本:IIS6
ASP.NET應用程式目錄:AAA_WEB
使用者近日常回報網頁偶而會出現『Server is too busy』的錯誤訊息。

 

原因

我們在使用者反應該問題時,將 ASP.NET Worker Process : aspnet_wp進行Dump,Dump 工具為DebudDialog ,並將dump檔交由微軟工程師進行解析,微軟回覆以下結果:

  1. 發生問題期間,由於ASP.NET bin目錄及config檔有異動,因此Application domain不斷地被shutdown。以下是解析片段:

    0:020> !DumpHttpRuntime
    Going to dump the HttpRuntimes found in the heap.
    HttpRuntime 0x1c6b41dc:
    _shutDownStack:    at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
       at System.Environment.get_StackTrace()
       at System.Web.HttpRuntime.ShutdownAppDomain()
       at System.Web.HttpRuntime.OnCriticalDirectoryChange(Object sender, FileChangeEvent e)
       at System.Web.FileChangesMonitor.OnCriticaldirChange(Object sender, FileChangeEvent e)
       at System.Web.DirectoryMonitor.FireNotifications()
       at System.Web.Util.WorkItem.CallCallbackWithAssert(WorkItemCallback callback)
       at System.Web.Util.WorkItem.OnQueueUserWorkItemCompletion(Object state)
       at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
    _shutDownMessage: Change Notification for critical directories.
    bin dir change or directory rename
    Change Notification for critical directories.
    bin dir change or directory rename
    Change Notification for critical directories.
    _shutdownInProgress: 1
    _requestQueue:
    0x186b8dd0
    _appDomainAppPath: C:\Inetpub\wwwroot\AAA_WEB\
    _appDomainAppId: /LM/W3SVC/1/ROOT
    _fcm:
    HttpRuntime 0x1c600544:
    _shutDownStack:    at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
       at System.Environment.get_StackTrace()
       at System.Web.HttpRuntime.ShutdownAppDomain()
       at System.Web.Hosting.HostingEnvironment.ShutdownThisAppDomainOnce()
       at System.Web.Hosting.HostingEnvironment.InitiateShutdownWorkItemCallback(Object state)
       at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
    _shutDownMessage: CONFIG change
    HostingEnvironment caused shutdown
    _shutdownInProgress: 1
    _requestQueue:
    0x185c2790
    _appDomainAppPath: C:\Inetpub\wwwroot\Public\
    _appDomainAppId: /LM/W3SVC/1/Root/Public
    _fcm:
    HttpRuntime 0x18563698:
    _shutDownStack:    at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
       at System.Environment.get_StackTrace()
       at System.Web.HttpRuntime.ShutdownAppDomain()
       at System.Web.HttpRuntime.OnCriticalDirectoryChange(Object sender, FileChangeEvent e)
       at System.Web.FileChangesMonitor.OnCriticaldirChange(Object sender, FileChangeEvent e)
       at System.Web.DirectoryMonitor.FireNotifications()
       at System.Web.Util.WorkItem.CallCallbackWithAssert(WorkItemCallback callback)
       at System.Web.Util.WorkItem.OnQueueUserWorkItemCompletion(Object state)
       at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
    _shutDownMessage: Change Notification for critical directories.
    bin dir change or directory rename
    Change Notification for critical directories.
    bin dir change or directory rename
    bin dir change or directory rename

    Change in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\3c653636\bc2125b3\hash.web
    Change in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\3c653636\bc2125b3\hash.web
    Change in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\3c653636\bc2125b3\hash.web
    _shutdownInProgress: 1
    _requestQueue:
    0x14564120
    _appDomainAppPath: C:\Inetpub\wwwroot\AAA_WEB\
    _appDomainAppId: /LM/W3SVC/1/ROOT
    _fcm:
  2. 同時也發現有多達1596次的AppDomainUnloadedException,原因同#1。
    Number of exceptions of this type:     1596
    Exception MethodTable: 7915cc88
    Exception object: 1ca9a59c
    Exception type: System.AppDomainUnloadedException
    Message: Attempted to access an unloaded AppDomain.
    InnerException: <none>
    StackTrace (generated):
    <none>
    StackTraceString: <none>
    HResult: 80131014
  3. 下列應用程式的debug沒有設定為false。
    0:020> !finddebugtrue
    Debug set to true for Runtime: 18563698, AppDomain: C:\Inetpub\wwwroot\AAA_WEB\
    Debug set to true for Runtime: 1c600544, AppDomain: C:\Inetpub\wwwroot\Public\
    Debug set to true for Runtime: 1c6b41dc, AppDomain: C:\Inetpub\wwwroot\AAA_WEB\

    Total 4 HttpRuntime objects
  4. Web 主機的.NET framework 2.0為RTM版本。
    0:020> !eeversion
    2.0.50727.42 retail

解決方法

請依下列作法解決此問題:

  1. 檢查Web Server的防毒軟體、檔案監控軟體等,將ASP.NET bin目錄Temporary ASP.NET Files等目錄加入不要被掃描的清單中,避免相關目錄或config檔案被修改導致application domain shut down,因為下列原因都會導致此問題:
    • Machine.Config, Web.Config or Global.asax 被修改
    • bin 目錄 or 其內容 被修改
    • aspx, ascx or asax重新編譯的次數超過 machine.config or web.config裡ompilation numRecompilesBeforeAppRestart=/> 的設定  (預設值是 15)
    • 應用程式虛擬目錄所指向之實體路徑被修改
    • CAS policy 被修改
    •  web service 被重新啟動
    •  Application(僅限2.0) 的子目錄被刪除
    參考:
    PRB: Session variables are lost intermittently in ASP.NET applications
    http://support.microsoft.com/kb/316148/en-us
    This problem can occur when antivirus software scans the Web application files. During the scanning process, the antivirus software may mark the Global.asax, the Web.config, and/or the Machine.config files as modified. This modification prompts the Microsoft .NET Framework restart the Web application. If the session data is stored in-process, all session data is lost whenever a Web application is restarted.
  2. 將下列ASP.NET debug設定false:
    C:\Inetpub\wwwroot\AAA_WEB\
    C:\Inetpub\wwwroot\Public\
    C:\Inetpub\wwwroot\AAA_WEB\
  3. 請將所有IIS 6的.NET framework 2.0升級至SP2:
    http://www.microsoft.com/downloads/zh-tw/details.aspx?FamilyID=5B2C0358-915B-4EB5-9B1D-10E506DA9D0F

沒有留言:

張貼留言