5

在IIS 6中,我們使用兩個第三方組件進行Url重寫:Helicon(用於處理無擴展url)和UrlRewriting.net。 前段時間我們遷移到IIS 7 - 經典模式,仍然使用這兩個組件。將IIS從經典模式切換到集成模式時鎖定和高CPU

現在我們試圖通過使用本地.Net路由來切換到沒有第三方組件的集成模式。 路由工作正常,但我們的Web應用程序表現完全不同。 我們的網絡服務器用於保持低於10%的CPU使用率,但現在很容易使用50%甚至更多。

我們已經開始分析內存轉儲,但似乎沒有找到問題的根源。 似乎.Net緩存機制阻止垃圾收集器?這與使用「集成模式」有什麼關係?

下面你會發現我們的分析摘錄。任何建議,看看下一步將不勝感激。

> !analyze -v -hang 
***************************** 
*               
*      Exception Analysis  
*               
***************************** 

GetPageUrlData failed, server returned HTTP status 404 
URL requested: http://watson.microsoft.com/00000000.htm?Retriage=1 

FAULTING_IP: 
+aceb6a0 
00000000`00000000 ??    ??? 

EXCEPTION_RECORD: ffffffffffffffff -- (.exr 0xffffffffffffffff) 
ExceptionAddress: 0000000000000000 
    ExceptionCode: 80000003 (Break instruction exception) 
    ExceptionFlags: 00000000 
NumberParameters: 0 

FAULTING_THREAD: 0000000000000022 
BUGCHECK_STR: HANG 
PROCESS_NAME: w3wp.exe 
ERROR_CODE: (NTSTATUS) 0xcfffffff - <Unable to get error code text> 
EXCEPTION_CODE: (NTSTATUS) 0xcfffffff - <Unable to get error code text> 
MOD_LIST: <ANALYSIS/> 
NTGLOBALFLAG: 0 
APPLICATION_VERIFIER_FLAGS: 0 

MANAGED_STACK: !dumpstack -EE 
OS Thread Id: 0x42ec (221) 
Current frame: 
Child-SP   RetAddr   Caller, Callee 
0000000016aee3f0 000007feecbae407 (MethodDesc 000007feec936b88 +0x77 DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, Int32, Boolean, IntPtr ByRef)) 
0000000016aee4f0 000007fef8408d0a (MethodDesc 000007fef81650a8 +0x4a System.Globalization.TextInfo.GetHashCodeOrdinalIgnoreCase(System.String)) 
0000000016aee510 000007feecbaea82 (MethodDesc 000007feec936d80 +0x42 DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr)) 
0000000016aee9e8 000007fef49b6f57 (MethodDesc 000007fef4993988 +0x47 System.Configuration.Internal.InternalConfigRoot.AcquireHierarchyLockForWrite()) 
0000000016aeeab0 000007fef49b6f57 (MethodDesc 000007fef4993988 +0x47 System.Configuration.Internal.InternalConfigRoot.AcquireHierarchyLockForWrite()) 
0000000016aeeae0 000007fef49c601e (MethodDesc 000007fef49870e0 +0x5e System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(System.String, System.Configuration.BaseConfigurationRecord)) 
0000000016aeeaf0 000007feecb18d36 (MethodDesc 000007feec99bc38 +0x86 System.Web.ApplicationImpersonationContext..ctor()) 
0000000016aeeb50 000007feecbab930 (MethodDesc 000007feec93acc8 +0x160 System.Web.Caching.CacheEntry.CallCacheItemRemovedCallback(System.Web.Caching.CacheItemRemovedCallback, System.Web.Caching.CacheItemRemovedReason)) 
0000000016aeeb70 000007feecbaae55 (MethodDesc 000007feec99e5a8 +0x75 System.Web.Caching.CacheDependency.DisposeInternal()) 
0000000016aeeba0 000007feecbac11d (MethodDesc 000007feec93cb88 +0x9d System.Web.Caching.CacheDependency.NotifyDependencyChanged(System.Object, System.EventArgs)) 
0000000016aeebf0 000007feecbaad3b (MethodDesc 000007feec93ace8 +0x16b System.Web.Caching.CacheEntry.Close(System.Web.Caching.CacheItemRemovedReason)) 
0000000016aeec70 000007feecb1538e (MethodDesc 000007feec99a9b0 +0x6fe System.Web.Caching.CacheSingle.UpdateCache(System.Web.Caching.CacheKey, System.Web.Caching.CacheEntry, Boolean, System.Web.Caching.CacheItemRemovedReason, System.Object ByRef)) 
0000000016aeed40 000007feecb14bdd (MethodDesc 000007feec99a248 +0x2d System.Web.Caching.CacheInternal.DoRemove(System.Web.Caching.CacheKey, System.Web.Caching.CacheItemRemovedReason)) 
0000000016aeed90 000007feecb4361d (MethodDesc 000007feec99ac80 +0x42d System.Web.Caching.ExpiresBucket.FlushExpiredItems(System.DateTime, Boolean)) 
0000000016aeee90 000007feecb43196 (MethodDesc 000007feec99aa68 +0x146 System.Web.Caching.CacheExpires.FlushExpiredItems(Boolean, Boolean)) 
0000000016aeeef0 000007fef8371839 (MethodDesc 000007fef807cd28 +0x9 System.Threading.Thread.get_CurrentThread()) 
0000000016aeef20 000007fef83717ec (MethodDesc 000007fef8090a70 +0xdc System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)) 
0000000016aeef40 000007fef83ec8ec (MethodDesc 000007fef8090ac8 +0x7c System.Threading.ExecutionContext.CreateCopy()) 
0000000016aeef80 000007fef83ecfa7 (MethodDesc 000007fef8098b30 +0x97 System.Threading._TimerCallback.PerformTimerCallback(System.Object)) 
0000000016aef230 000007feed2ab8f4 (MethodDesc 000007feec9ec4c0 +0x6f4 System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)) 
0000000016aef4a0 000007feed2a9ef1 (MethodDesc 000007feec9d2dc8 +0x51 DomainNeutralILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)) 

DERIVED_WAIT_CHAIN: 

Dl Eid Cid  WaitType 
-- --- ------- -------------------------- 
    0 1414.168c Speculated (Triage) --> 
    34 1414.1ca4 Unknown     

WAIT_CHAIN_COMMAND: ~0s;k;;~34s;k;; 
BLOCKING_THREAD: 0000000000001ca4 
DEFAULT_BUCKET_ID: APPLICATION_HANG_BusyHang 
PRIMARY_PROBLEM_CLASS: APPLICATION_HANG_BusyHang 
LAST_CONTROL_TRANSFER: from 000007fef951579e to 000007fef95155e1 

STACK_TEXT: 
00000000`0850f4c0 000007fe`f951579e : 00000000`03735c20 00000002`6f7f8e08 00000001`7f3ce748 00000000`107bdf08 : clr!SVR::gc_heap::mark_object_simple1+0x458 
00000000`0850f560 000007fe`f9513745 : 00000000`03735c20 000007fe`ecc2d808 00000000`00000002 000007fe`ecc2d808 : clr!SVR::gc_heap::mark_object_simple+0x4d7 
00000000`0850f5f0 000007fe`f9418987 : 00000001`7f3ce748 00000000`03735c20 00000000`201617f8 0000e5b3`06a4c486 : clr!SVR::GCHeap::Promote+0x161 
00000000`0850f670 000007fe`f9418c77 : 00000000`201617f8 000007fe`f9418940 ffffffff`fffffe00 00000000`20161800 : clr!CalculateSizedRefSize+0x47 
00000000`0850f6a0 000007fe`f9418be1 : 00000000`000000c0 00000000`00000001 00000000`00000003 00000000`0850f728 : clr!ScanConsecutiveHandlesWithUserData+0x67 
00000000`0850f6e0 000007fe`f950dcb2 : 00000000`20160000 000007fe`f9418b88 00000000`00000003 00000000`0370d0b0 : clr!BlockScanBlocksWithUserData+0x59 
00000000`0850f720 000007fe`f950d275 : 00000000`0850f8a0 00000000`0850f910 000007fe`f9418b88 00000000`0850f910 : clr!TableScanHandles+0x219 
00000000`0850f7e0 000007fe`f9418ac8 : 00000000`00000002 00000000`00000008 00000000`00000008 00000007`ff316000 : clr!HndScanHandlesForGC+0x1ad 
00000000`0850f890 000007fe`f95934c6 : 00000000`03735c20 000007fe`f95134b0 00000000`00000002 00000000`00000008 : clr!ScanSizedRefByAD+0xf8 
00000000`0850f930 000007fe`f9511a43 : 00000000`03735c20 00000000`00000002 00000000`03735c20 000007fe`00000001 : clr!SVR::gc_heap::mark_phase+0x19c 
00000000`0850f9c0 000007fe`f9512632 : 00000005`24fe3bc1 00000000`00000000 00000000`037363f8 00000000`03735c20 : clr!SVR::gc_heap::gc1+0x54 
00000000`0850fa30 000007fe`f9511758 : 00000000`00000000 00000000`01120f30 00000000`01680000 00000000`00000000 : clr!SVR::gc_heap::garbage_collect+0x372 
00000000`0850fac0 000007fe`f958a0cb : 00000000`0000406b 00000000`03735c20 00000000`0850fd40 00000000`00000000 : clr!SVR::gc_heap::gc_thread_function+0x78 
00000000`0850fb10 00000000`7728652d : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : clr!SVR::gc_heap::gc_thread_stub+0x82 
00000000`0850fd60 00000000`7771c521 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : kernel32!BaseThreadInitThunk+0xd 
00000000`0850fd90 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x1d 

FOLLOWUP_IP: 
clr!SVR::gc_heap::gc_thread_stub+82 
000007fe`f958a0cb cc    int  3 

SYMBOL_STACK_INDEX: d 
SYMBOL_NAME: clr!SVR::gc_heap::gc_thread_stub+82 
FOLLOWUP_NAME: MachineOwner 
MODULE_NAME: clr 
IMAGE_NAME: clr.dll 
DEBUG_FLR_IMAGE_TIMESTAMP: 4e1822f4 
STACK_COMMAND: ~34s ; kb 
BUCKET_ID: X64_HANG_clr!SVR::gc_heap::gc_thread_stub+82 
FAILURE_BUCKET_ID: APPLICATION_HANG_BusyHang_cfffffff_clr.dll!SVR::gc_heap::gc_thread_stub 
WATSON_STAGEONE_URL: http://watson.microsoft.com/00000000.htm?Retriage=1 

Followup: MachineOwner 
--------- 

> !clrstack 
OS Thread Id: 0x42ec (221) 
Child SP   IP    Call Site 
0000000016aee998 00000000777418ca [HelperMethodFrame_1OBJ: 0000000016aee998] System.Threading.ReaderWriterLock.AcquireWriterLockInternal(Int32) 
0000000016aeeac0 000007fef49b6f57 System.Configuration.Internal.InternalConfigRoot.AcquireHierarchyLockForWrite() 
0000000016aeeaf0 000007fef49c601e System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(System.String, System.Configuration.BaseConfigurationRecord) 
0000000016aeeb60 000007feecbab930 System.Web.Caching.CacheEntry.CallCacheItemRemovedCallback(System.Web.Caching.CacheItemRemovedCallback, System.Web.Caching.CacheItemRemovedReason) 
0000000016aeec00 000007feecbaad3b System.Web.Caching.CacheEntry.Close(System.Web.Caching.CacheItemRemovedReason) 
0000000016aeec80 000007feecb1538e System.Web.Caching.CacheSingle.UpdateCache(System.Web.Caching.CacheKey, System.Web.Caching.CacheEntry, Boolean, System.Web.Caching.CacheItemRemovedReason, System.Object ByRef) 
0000000016aeed50 000007feecb14bdd System.Web.Caching.CacheInternal.DoRemove(System.Web.Caching.CacheKey, System.Web.Caching.CacheItemRemovedReason) 
0000000016aeeda0 000007feecb4361d System.Web.Caching.ExpiresBucket.FlushExpiredItems(System.DateTime, Boolean) 
0000000016aeeea0 000007feecb43196 System.Web.Caching.CacheExpires.FlushExpiredItems(Boolean, Boolean) 
0000000016aeef30 000007fef83717ec System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
0000000016aeef90 000007fef83ecfa7 System.Threading._TimerCallback.PerformTimerCallback(System.Object) 
0000000016aef208 000007fef9399714 [GCFrame: 0000000016aef208] 
0000000016aef3e0 000007fef9399714 [DebuggerU2MCatchHandlerFrame: 0000000016aef3e0] 
0000000016aef5b8 000007fef9399714 [ContextTransitionFrame: 0000000016aef5b8] 
0000000016aef7a0 000007fef9399714 [DebuggerU2MCatchHandlerFrame: 0000000016aef7a0] 

> !syncblk 
Index   SyncBlock MonitorHeld Recursion Owning Thread Info   SyncBlock Owner 
7906 0000000015d167c8   1   1 000000000fdbee90 405c 270 000000010f37d138 System.Dynamic.Utils.CacheDict`2[[System.Type, mscorlib],[System.Reflection.MethodInfo, mscorlib]] 
8144 00000000153c3038   3   1 0000000015e0f1f0 4338 228 000000021f79e8b0 System.Web.CachedPathData 
26403 00000000154b5e58   5   1 0000000010bdb640 42b8 119 00000001cf83a158 System.Web.CachedPathData 
26600 000000000fd0e0d8   3   1 000000001d006e60 403c 311 000000025f712b40 System.Web.CachedPathData 
26677 000000001519c558   3   1 000000001eff0540 36e8 327 000000020f664fb8 System.Web.CachedPathData 
27056 000000001519f428   5   1 000000001c862340 34e0 294 000000018f5fd5b8 System.Object 
27174 000000000ce4b628   1   1 000000000fe5c830 464c 212 00000001ff6ed2a8 System.Web.DirectoryMonitor 
27227 00000000107207d8   3   1 000000001f9b0cb0 47b4 260 000000016f85dcb8 System.Web.CachedPathData 
27426 000000000c9ef2e8   3   1 000000000cbd3ff0 4058 131 00000001ff5a2ce8 System.Web.CachedPathData 
27677 000000000ccee958   3   1 0000000015fa5d10 3b78 236 000000015f681dc8 System.Web.CachedPathData 
27680 000000000ccd9588   3   1 00000000159aa750 4200 180 000000019fa2b008 System.Web.CachedPathData 
27728 000000000c804c98   3   1 00000000159aae60 4568 211 00000001ff576860 System.Web.CachedPathData 
27831 000000000a2d2a58   3   1 000000000cba4df0 43cc 127 00000000ff6f45a0 System.Web.CachedPathData 
28088 00000000159b9688   5   1 000000001d139d30 3c40 177 000000023f887808 System.Web.CachedPathData 
28491 00000000102d2fb8   7   1 000000000cacd460 411c 150 000000010f697cc8 System.Web.CachedPathData 
28637 000000000a2d5f88   9   1 000000001ca9e8e0 41a8 130 000000024f6be1e8 System.Web.CachedPathData 
28672 000000000c8675f8   3   1 000000000cbc38e0 40c4 151 000000018f481828 System.Web.CachedPathData 
----------------------------- 
Total   29135 
CCW    2 
RCW    2 
ComClassFactory 0 
Free   22330 

> !threadpool 
CPU utilization: 74% 
Worker Thread: Total: 196 Running: 196 Idle: 0 MaxLimit: 2400 MinLimit: 24 
Work Request in Queue: 32 
    Unknown Function: 000007feefe898e0 Context: 00000000109e2d10 
    Unknown Function: 000007feefe898e0 Context: 000000001d346680 
    AsyncTimerCallbackCompletion [email protected] 
    AsyncTimerCallbackCompletion [email protected] 
    AsyncTimerCallbackCompletion [email protected] 
    Unknown Function: 000007feefe898e0 Context: 000000001ed65ad0 
    Unknown Function: 000007feefe898e0 Context: 000000000a1bc1c0 
    Unknown Function: 000007feefe898e0 Context: 000000001ef443e0 
    Unknown Function: 000007feefe898e0 Context: 0000000015410af0 
    Unknown Function: 000007feefe898e0 Context: 000000000fd96330 
    Unknown Function: 000007feefe898e0 Context: 000000001d624860 
    Unknown Function: 000007feefe898e0 Context: 000000000fc6e500 
    Unknown Function: 000007feefe898e0 Context: 0000000015b8e110 
    Unknown Function: 000007feefe898e0 Context: 00000000158dc6b0 
    Unknown Function: 000007feefe898e0 Context: 000000001f1ab600 
    Unknown Function: 000007feefe898e0 Context: 000000000cf05e38 
    Unknown Function: 000007feefe898e0 Context: 000000001d0b1c50 
    AsyncTimerCallbackCompletion [email protected] 
    Unknown Function: 000007feefe898e0 Context: 000000001c926f10 
    Unknown Function: 000007feefe898e0 Context: 000000001d472c80 
    Unknown Function: 000007feefe898e0 Context: 000000000cf15af0 
    Unknown Function: 000007feefe898e0 Context: 000000001f5b00c0 
    Unknown Function: 000007feefe898e0 Context: 000000000a022fa0 
    Unknown Function: 000007feefe898e0 Context: 000000001049d2e0 
    Unknown Function: 000007feefe898e0 Context: 00000000105e9370 
    AsyncTimerCallbackCompletion [email protected] 
    Unknown Function: 000007feefe898e0 Context: 000000001d376960 
    Unknown Function: 000007feefe898e0 Context: 000000001ee3f0d0 
    Unknown Function: 000007feefe898e0 Context: 000000001ee325b0 
    Unknown Function: 000007feefe898e0 Context: 0000000015f726b0 
    Unknown Function: 000007feefe898e0 Context: 0000000015598480 
    Unknown Function: 000007feefe898e0 Context: 000000000ce2a8a0 
-------------------------------------- 
Number of Timers: 80 
-------------------------------------- 
Completion Port Thread:Total: 5 Free: 3 MaxFree: 48 CurrentLimit: 5 MaxLimit: 2400 MinLimit: 24 
+1

您可以使用sysinternals中的ProcessExplorer和FileMonitor來查看進程和文件發生了什麼? – Aristos 2012-02-12 11:12:34

+0

我們確實附加了ProcessExplorer,但它並沒有給我們提供更好的見解。沒有使用FileMonitor,那現在是ProcessMonitor的一部分?我們會試試看看它是否爲我們提供了更多信息。謝謝你的建議。 – Jacco 2012-02-12 21:44:50

+0

FileMonitor是獨立的,可以幫助看到什麼是閱讀,你可以得到一個想法,如果文件閱讀造成問題。 ProcessExplorer你看到了什麼在吃cpu嗎? – Aristos 2012-02-12 21:49:46

回答

3

好吧,發現問題和解決。 這個週末有人指着我this Server Fault question。這似乎是合理的,通過路由模塊發送所有請求肯定會導致性能問題。 經過其他一些帖子後,我意識到這是一個配置問題。我們通過所有管理模塊發送的所有請求:

<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    </system.webServer> 

此設置爲和我們的Web應用程序現在表現如預期。

@Aristos:即使我沒有跟進你的建議,謝謝你的想法。

0

這是一個臨時解決方案。如果將來要改變你的應用程序並使用一些託管模塊(這使得Web開發變得容易),你不會。您已禁用所有請求的所有託管模塊,這意味着您不能從您的應用中的託管模塊中受益。

由於更改config已解決您的問題沒有任何缺點(應用程序像以前一樣工作,沒有功能關閉),我想你有很多不必要的模塊加載到你的應用程序,每消耗大量的資源請求。 IIS不知道模塊是否必須對某個請求執行某些操作,因此如果您已經爲請求類型加載了該模塊,則IIS會將該請求傳遞給託管代碼,並且這些不必要的轉換會消耗一些資源(當模塊無關)。 嘗試從您的web.config中刪除任何不必要的模塊,並將配置更改回runAllManagedModulesForAllRequests="true",除非您確信未來不需要託管模塊。

注意:您可能不會親自添加此模塊。其中很多是通過第三方解決方案(即使用CAPTCHA模塊)添加的,但他們無法發現您已更改計劃並刪除了第三方解決方案,因此該模塊仍保留在Bin文件夾(或GAC)中,並且該行不會被刪除從您的config文件。