Usually when dynamic pages (ASPX) have slow responding issue, we can still get satisfied performance with static pages (HTML, GIF, CSS…). Because they are loaded on different request handling stacks and static pages loading by default doesn’t require compile/rendering/Executing on server side.
However recently I met one case that both static and dynamic Pages are loading very slowly intermittently, this is not related to networking because it even happens for localhost. When the issue starts happening, recycling application pool doesn’t help. Customer has to wait long time.
To resolve this issue, we captured memory dump files when issue occurred. Found customer put some heavy logic in Application_Start, and all other working threads are pending on application start completion:
ChildEBP RetAddr Args to Child
0183f01c 77453bc8 00000000 0183f060 9f2fe87c ntdll!ZwDelayExecution+0x15
0163f084 77455598 00000064 00000000 01f430c8 KERNELBASE!SleepEx+0x65
0163f094 73ab78a5 00000064 011390d0 0001ffff KERNELBASE!Sleep+0xf
0163f0c8 73ab5504 00000002 011930d0 01139030 iisutil!CReaderWriterLock3::_LockSpin+0xfb
0163f0e8 739b258d 00000000 800700b7 739b3771 iisutil!CReaderWriterLock3::ReadLock+0x3c
0163f0f4 739b3771 00ef77c0 00ef8d10 00fe77c0 iiscore!W3_APPLICATION::WaitForStartComplete+0x14
0163fa70 739a071c 00ef77c0 00fe8d10 0183fab8 iiscore!W3_APPLICATION_TABLE::GetApplication+0x68d
0163fa90 739a443a 0138fab8 00ef66c4 00fe77c0 iiscore!W3_CONTEXT::SetupApplication+0x39
0163fac4 739a5ab3 00fe77c0 00fe66c4 00000000 iiscore!W3_CONTEXT::SetupStateMachinePhase2+0x13b
0163fb38 739a61c3 00fe77c4 00fe66c0 763b1400 iiscore!W3_CONTEXT::SetupStateMachine+0x241
0163fb4c 739a6642 00fe77c4 00000000 01108aa8 iiscore!W3_MAIN_CONTEXT::StartNotificationLoop+0x3f
0163fb64 73f31568 00fe6d68 00fed668 73f314e6 iiscore!W3_MAIN_CONTEXT::OnNewRequest+0x47
From further local tests, we can confirm that Application_Start slowness in ASP.NET can blocking all kinds of requests, including static pages when the Application Pool mode is Integration Pipeline Mode.
To resolve this issue, we should always avoid put complicated logic in Application_Start for ASP.NET.
Note: If we choose Classic Application Pool mode, static pages can be loaded quickly without being impacted by ASP.NET. This only happens when using Integrated Mode Application Pool.
Freist Li from APGC DSI Team