<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>thinking in geek &#187; iis</title>
	<atom:link href="http://joshrobb.com/blog/category/iis/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshrobb.com/blog</link>
	<description>tagline's are so web2.0</description>
	<lastBuildDate>Wed, 02 Jun 2010 14:47:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>You know you’re having a bad day when&#8230;</title>
		<link>http://joshrobb.com/blog/2007/06/28/you-know-you%e2%80%99re-having-a-bad-day-when/</link>
		<comments>http://joshrobb.com/blog/2007/06/28/you-know-you%e2%80%99re-having-a-bad-day-when/#comments</comments>
		<pubDate>Thu, 28 Jun 2007 17:02:14 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[iis]]></category>

		<guid isPermaLink="false">http://joshrobb.com/blog/2007/06/28/you-know-you%e2%80%99re-having-a-bad-day-when/</guid>
		<description><![CDATA[You walk into the office and get told that you need to drop everything you were going to be working on because there&#8217;s a recurring problem on the production servers. For the last few days we&#8217;ve been experiencing a 100% CPU utilization on the w3wp.exe (the asp.net worker) process. Killing it off will fix the [...]]]></description>
			<content:encoded><![CDATA[<p>You walk into the office and get told that you need to drop everything you were going to be working on because there&#8217;s a recurring problem on the production servers. For the last few days we&#8217;ve been experiencing a 100% CPU utilization on the w3wp.exe (the asp.net worker) process. Killing it off will fix the problem temporarily &#8211; but it will start up again sooner or later. Time to start production debugging!</p>
<ol>
<li>Install the <a href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx">Debugging Tools for Windows</a> and thank the good Lord you&#8217;ve been reading <a href="http://blogs.msdn.com/tess/">Tess&#8217;s blog</a>.</li>
<li>Create a &#8220;hang&#8221; dump of the process.
<p style="text-align: justify"><span style="font-family: Courier">&gt; adplus -hang -p 1680<br />
</span></li>
<li> Open the dump in windbg.exe
<p style="text-align: justify"><span style="font-family: Courier">&gt;windbg.exe -z Hang_Mode__Date_06-28-2007__Time_11-21-2020<br />
</span></li>
<li>Load <a href="http://msdn2.microsoft.com/en-us/library/ms404370(VS.80).aspx">sos.dll</a> &#8211; the debug helper for the CLR.
<p style="text-align: justify"><span style="font-family: Courier">&gt; .load C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\sos.dll<br />
</span></li>
<li>Checkout what&#8217;s happening in the CLR thread pool.
<p><span style="font-family: Courier">0:000&gt; !threadpool<br />
CPU utilization 100%<br />
Worker Thread: Total: 3 Running: 2 Idle: 1 MaxLimit: 200 MinLimit: 2<br />
Work Request in Queue: 0<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Number of Timers: 9<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Completion Port Thread:Total: 2 Free: 1 MaxFree: 4 CurrentLimit: 2 MaxLimit: 200 MinLimit: 2<br />
</span></li>
<li>There are two CLR threads running. Wonder what they&#8217;re doing? Are they GC&#8217;ing or in user code? Let&#8217;s take a look at what&#8217;s happening with the OS threads.
<p><span style="font-family: Courier">0:000&gt; !threads<br />
ThreadCount: 8<br />
UnstartedThread: 0<br />
BackgroundThread: 8<br />
PendingThread: 0<br />
DeadThread: 0<br />
Hosted Runtime: no<br />
PreEmptive GC Alloc Lock<br />
ID OSID ThreadOBJ State GC Context Domain Count APT Exception<br />
13 1 90c 000dc6e8 1808220 Enabled 02b64538:02b65458 000d9710 0 Ukn (Threadpool Worker)<br />
17 2 fdc 000e2fc8 b220 Enabled 00000000:00000000 000d9710 0 MTA (Finalizer)<br />
18 3 38c 000f7798 80a220 Enabled 00000000:00000000 000d9710 0 MTA (Threadpool Completion Port)<br />
19 4 84c 000fa800 1220 Enabled 00000000:00000000 000d9710 0 Ukn<br />
11 5 cd0 00116b30 880a220 Enabled 00000000:00000000 000d9710 0 MTA (Threadpool Completion Port)<br />
<strong>21 6 e94 0ebd6bc8 180b220 Disabled 00000000:00000000 000fb1a0 1 MTA (Threadpool Worker)<br />
22 8 b70 0ebde1a8 180b220 Disabled 00000000:00000000 000fb1a0 1 MTA (Threadpool Worker)</strong><br />
23 7 e14 0ec0a378 880b220 Enabled 00000000:00000000 000d9710 0 MTA (Threadpool Completion Port)<br />
</span></li>
<li>There&#8217;s two threads running user code there &#8211; are they the ones that are pegging the CPU? Let&#8217;s see.
<p><span style="font-family: Courier">0:000&gt; !runaway<br />
User Mode Time<br />
Thread Time<br />
<strong>21:e94 0 days 0:19:50.296<br />
22:b70 0 days 0:15:38.625</strong><br />
13:90c 0 days 0:00:07.062<br />
15:934 0 days 0:00:00.156<br />
16:a38 0 days 0:00:00.140<br />
3:bec 0 days 0:00:00.062<br />
5:538 0 days 0:00:00.046<br />
0:2e0 0 days 0:00:00.046<br />
28:6f0 0 days 0:00:00.000<br />
27:a3c 0 days 0:00:00.000<br />
26:530 0 days 0:00:00.000<br />
25:358 0 days 0:00:00.000<br />
24:b8c 0 days 0:00:00.000<br />
23:e14 0 days 0:00:00.000<br />
20:9e8 0 days 0:00:00.000<br />
19:84c 0 days 0:00:00.000<br />
18:38c 0 days 0:00:00.000<br />
17:fdc 0 days 0:00:00.000<br />
14:5d4 0 days 0:00:00.000<br />
12:ab8 0 days 0:00:00.000<br />
11:cd0 0 days 0:00:00.000<br />
10:f1c 0 days 0:00:00.000<br />
9:ac4 0 days 0:00:00.000<br />
8:a40 0 days 0:00:00.000<br />
7:a24 0 days 0:00:00.000<br />
6:c84 0 days 0:00:00.000<br />
4:f94 0 days 0:00:00.000<br />
2:bb0 0 days 0:00:00.000<br />
1:270 0 days 0:00:00.000<br />
</span></li>
<li>Yep &#8211; the two CLR threads are chewing all the CPU. Let&#8217;s switch our thread context to the first one. (21).
<p><span style="font-family: Courier">0:006&gt; ~21 s<br />
eax=026bcd88 ebx=026bcd01 ecx=026bcd88 edx=02702a44 esi=026bcd88 edi=026bf064<br />
eip=0ee0709e esp=0eeff1ec ebp=026bcd88 iopl=0 nv up ei ng nz na pe cy<br />
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000287<br />
Demo!Models.CMSPage.IsSubPage(Models.CMSPage)+0&#215;56:<br />
0ee0709e 0fb6db movzx ebx,bl<br />
</span></li>
<li>Let&#8217;s take a look at what managed objects are reachable from the current stack.
<p><span style="font-family: Courier">0:021&gt; !dso<br />
OS Thread Id: 0xe94 (21)<br />
ESP/REG Object Name<br />
<strong>eax 026bcd88 Models.CMSPage<br />
ecx 026bcd88 Models.CMSPage<br />
esi 026bcd88 Models.CMSPage<br />
edi 026bf064 Models.CMSPage<br />
ebp 026bcd88 Models.CMSPage<br />
0eeff1f8 026bcd88 Models.CMSPage<br />
</strong>0eeff1fc 026bf064 Models.CMSPage<br />
0eeff208 06529858 System.String &lt;ul id=&#8221;menu-level{0}&#8221;&gt;<br />
0eeff238 026cd1cc System.Object[] (Models.CMSPage[])<br />
0eeff240 790d6584 System.String<br />
0eeff244 026b906c ASP.skins_demo_master_master<br />
0eeff284 026b906c ASP.skins_demo_master_master<br />
0eeff28c 026bdea4 System.Text.StringBuilder<br />
0eeff29c 026cd1cc System.Object[] (Models.CMSPage[])<br />
0eeff2a0 026bdea4 System.Text.StringBuilder<br />
0eeff2a4 026cd1cc System.Object[] (Models.CMSPage[])<br />
0eeff2a8 026bcd88 Models.CMSPage<br />
0eeff2b8 026b906c ASP.skins_demo_master_master<br />
0eeff2bc 026bdd2c System.Web.UI.HtmlControls.HtmlLink<br />
0eeff2cc 026df978 System.Object<br />
0eeff2d0 024af58c System.String class<br />
0eeff2dc 0651f798 System.String screen.css<br />
0eeff2f8 026b906c ASP.skins_demo_master_master<br />
0eeff310 024a793c System.EventArgs<br />
0eeff33c 026b906c ASP.skins_demo_master_master<br />
0eeff350 026b4bdc ASP.default_aspx<br />
0eeff374 790d6584 System.String<br />
0eeff37c 026afcf4 System.Web.HttpContext<br />
0eeff380 026b4bdc ASP.default_aspx<br />
0eeff514 026b4bdc ASP.default_aspx<br />
0eeff528 026b4bdc ASP.default_aspx<br />
0eeff558 02464340 System.Globalization.CultureInfo<br />
0eeff55c 02464110 System.Globalization.CultureInfo<br />
0eeff560 025beff0 System.Threading.Thread<br />
0eeff564 026b4bdc ASP.default_aspx<br />
0eeff59c 026afcf4 System.Web.HttpContext<br />
0eeff5a0 026b4bdc ASP.default_aspx<br />
0eeff5bc 026afcf4 System.Web.HttpContext<br />
0eeff5c0 025d1084 System.Web.HttpApplication+CallHandlerExecutionStep<br />
0eeff5f8 025d1084 System.Web.HttpApplication+CallHandlerExecutionStep<br />
0eeff5fc 025beeb0 ASP.global_asax<br />
0eeff62c 025beeb0 ASP.global_asax<br />
0eeff630 026affb4 System.Web.HttpApplication+ThreadContext<br />
0eeff634 025e54a0 System.Web.AspNetSynchronizationContext<br />
0eeff63c 025beeb0 ASP.global_asax<br />
0eeff668 026aff98 System.Web.HttpAsyncResult<br />
0eeff690 026afcf4 System.Web.HttpContext<br />
0eeff694 026af6ac System.Web.Hosting.ISAPIWorkerRequestInProcForIIS6<br />
0eeff698 02477fb0 System.Web.HttpRuntime<br />
0eeff6e0 0247b8e4 System.Web.Caching.CacheSingle<br />
0eeff700 0248e4a4 System.Web.Hosting.ISAPIRuntime<br />
</span></li>
<li>Himmm.. we have the same instance (026bcd88) of that CMSPage object floating around in a bunch of places. I wonder if we have some bad data in the database. This class has a parent/child relationship with itself. Could it be causing an infinite loop?
<p><span style="font-family: Courier">0:021&gt; !do 026bcd88<br />
Name: Models.CMSPage<br />
MethodTable: 0e941234<br />
EEClass: 0244cc60<br />
Size: 92(0x5c) bytes<br />
(C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\5bf6c3da\19d72350\assembly\dl3\36150507\00d93296_9ca7c701\Demo.DLL)<br />
Fields:<br />
MT Field Offset Type VT Attr Value Name<br />
0e942118 4000140 40 &#8230;sionFactoryHolder 0 static 024c4e34 holder<br />
791036b0 4000147 4 &#8230;ections.ArrayList 0 instance 026bcde4 __validators<br />
79113dfc 4000148 8 &#8230;tions.IDictionary 0 instance 00000000 __failedProperties<br />
79124228 4000149 c System.Object[] 0 instance 00000000 _errorMessages<br />
790fed1c 40000f7 40 System.Int32 0 instance 102 _id<br />
790fa3e0 40000f8 18 System.String 0 instance 026bc668 _name<br />
790fa3e0 40000f9 1c System.String 0 instance 00000000 _url<br />
790fa3e0 40000fa 20 System.String 0 instance 026bc6a0 _title<br />
790fa3e0 40000fb 24 System.String 0 instance 026bc768 _content<br />
790fa3e0 40000fc 28 System.String 0 instance 026bc6c8 _heading<br />
790fa3e0 40000fd 2c System.String 0 instance 026bc6e4 _metaDescription<br />
790fa3e0 40000fe 30 System.String 0 instance 026bc71c _metaKeyWords<br />
0e941174 40000ff 44 System.Int32 0 instance 2 _status<br />
791059c0 4000100 10 System.Double 0 instance 1.000000 _displayOrder<br />
<strong>0e941234 4000101 34 Models.CMSPage 0 instance 026bcd88 _parent<br />
</strong>7910e274 4000102 38 &#8230;Collections.IList 0 instance 026bcef0 _children<br />
79105ef0 4000103 48 System.DateTime 1 instance 026bcdd0 _dateUpdatedAt<br />
79105ef0 4000104 50 System.DateTime 1 instance 026bcdd8 _dateCreatedAt<br />
0e94337c 4000105 3c Models.Site 0 instance 026b8e30 _Site<br />
</span></li>
<li>11. Yep &#8211; check that &#8211; the _parent field of instance 026bcd88 is pointing at itself (026bcd88). Log into the database and manually patch up the data. Next job &#8211; write some more defensive code around how that works.</li>
</ol>
<p>Well &#8211; I hope you enjoyed that. Production debugging is always fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://joshrobb.com/blog/2007/06/28/you-know-you%e2%80%99re-having-a-bad-day-when/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Monorail + URL Rewriting</title>
		<link>http://joshrobb.com/blog/2007/04/26/monorail-url-rewriting/</link>
		<comments>http://joshrobb.com/blog/2007/04/26/monorail-url-rewriting/#comments</comments>
		<pubDate>Thu, 26 Apr 2007 10:10:48 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[castle]]></category>
		<category><![CDATA[iis]]></category>

		<guid isPermaLink="false">http://joshrobb.com/blog/2007/04/26/monorail-url-rewriting/</guid>
		<description><![CDATA[Often people need or want clean URLs (i.e. URL&#8217;s without file extensions). e.g. Not http://example.com/somecontroller/someaction.aspx but http://example.com/somecontroller/someaction Previously there&#8217;s been two options for this. Either mapping all requests to aspnet_isapi.dll which has serious performance implications &#8211; or using ISAPI Rewrite from Helicon Software. There&#8217;s a newish (to me anyway) alternative to ISAPI rewrite which is [...]]]></description>
			<content:encoded><![CDATA[<p>Often people need or want  clean URLs (i.e. URL&#8217;s without file extensions). e.g.</p>
<p>Not<br />
<a href="http://joshrobb.com/somecontroller/someaction.aspx">http://example.com/somecontroller/someaction.aspx</a><br />
but<br />
<a href="http://example.com/somecontroller/someaction">http://example.com/somecontroller/someaction</a></p>
<p>Previously there&#8217;s been two options for this. Either mapping all requests to aspnet_isapi.dll which has serious performance implications &#8211; or using <a href="http://www.isapirewrite.com/">ISAPI Rewrite</a> from Helicon Software.</p>
<p>There&#8217;s a newish (to me anyway) alternative to ISAPI rewrite which is open source (BSD) <a href="http://www.codeplex.com/IIRF">Ionics Isapi Rewrite Filter</a> &#8211; It&#8217;s got some really nice features that ISAPIRewrite doesn&#8217;t have. Specifically it supports the following setup:</p>
<pre>RewriteCond %{REQUEST_FILENAME}     !-f
RewriteCond %{REQUEST_FILENAME}     !-d
RewriteRule ^.*$     /default.aspx     [U,I,L]</pre>
<p>This checks the incoming request does not match an existing file/directory on the filesystem before it rewrites the request.</p>
<p>This is a feature that apache users have had in mod_rewrite forever &#8211; but it&#8217;s really helpful for us IIS users because it avoids all the overhead associated with mapping all requests to the aspnet_filter.dll. You can leave IIS configured as it is and any incoming requests which do not refer to existing files ( e.g. stylesheets/images/javascripts etc) will be processed by the <a href="http://asp.net/">ASP.NET</a> runtime where the monorail can take them over.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshrobb.com/blog/2007/04/26/monorail-url-rewriting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
