Scott Forsyth's Blog

Postings on IIS, ASP.NET, SQL Server, Webfarms and general system admin.

.

  • Scott Forsyth

Hosting Needs

Training and Dev Labs

SiteServerDetails–Obtaining information about a server node in a web farm—Part 13 of 52

This week I cover a couple ways to obtain information about a specific server in a web farm.  How can you tell which node handled your page request? Often it’s valuable to know which node is currently being served for troubleshooting the load balancer or individual pages.

I posted another non-video blog post this morning that covers this same topic and provides the download link to SiteServerDetails.

This is week 13 of a 52 week series on various web administration related tasks. Past and future videos can be found here.

Today’s video walks through this HTTP Handler and how you can install it on your web farm.  Just now I realized that I forgot to mention how to roll this out on a full web farm with multiple nodes (the target install situation). 

The install won’t break anything, even if you install it while shared configuration is enabled.  Simply run the quick install on each node of the web farm and it will install without any impact to the production environment.

Having problems viewing on your mobile device? Click here instead.

Comments

imran_ku07 said:

There are also some other important information available for administrator. As given in,

bradwilson.typepad.com/.../diagnosing-aspnet-mvc-problems.html

weblogs.asp.net/.../monitoring-asp-net-mvc-application.aspx

May be you will cover these information in your next videos.

# April 3, 2011 3:30 AM

OWScott said:

Thanks Imran.  That's great feedback.  You're right, there's some great tools available now for monitoring the application performance.  I added the suggestion to my video series agenda.  Not sure which items I'll get to or not but it's definitely noted.

# April 4, 2011 10:15 AM

Mikhail Petrovskikh said:

The problem is that for a load balancer requests to a url and url/siteserverdetails.axd can come from different nodes. I usually use Fiddler and insert host name and IP in an "X-" header using URL Rewrite outbound rules.

Advantage - no need to install anything because you already have URL Rewrite on your Web Farm nodes. All done by appcmd.

Disadvantage - a potential slight overhead (never observed) for URL Rewrite processing

REM Next line is a workaround because URL Rewrite needs something to "rewrite" it can't add a header to Http Response. Adding custom header X-Responding-Host which can be seen in Fiddler and any network monitoring tools for every response

appcmd set config  -section:system.webServer/httpProtocol /+"customHeaders.[name='X-Responding-Host',value='*']" /commit:apphost

REM create outbound rewrite rule for the server

appcmd set config  -section:rewrite/outboundRules /+"[name='X-Responding-Host',patternSyntax='Wildcard',stopProcessing='True']" /commit:apphost

REM add condition and action to the rule

REM None rule syntax for matching response header name, it needs prefix "RESPONSE_" and all dashes replaced with underscore

appcmd set config  -section:rewrite/outboundRules /[name='X-Responding-Host'].conditions.trackAllCaptures:"False" /[name='X-Responding-Host'].match.serverVariable:"RESPONSE_X_Responding_Host" /[name='X-Responding-Host'].match.pattern:"*" /[name='X-Responding-Host'].action.type:"Rewrite" /[name='X-Responding-Host'].action.value:"{SERVER_NAME}/{LOCAL_ADDR}" /commit:apphost

The above adds the following in applicationHost.config

in <configuration><system.webServer>

under <httpProtocol><customHeaders>

<add name="X-Responding-Host" value="*" />

and under <rewrite><outboundRules>

               <rule name="X-Responding-Host" patternSyntax="Wildcard" stopProcessing="true">

                   <match serverVariable="RESPONSE_X_Responding_Host" pattern="*" />

                   <conditions trackAllCaptures="false" />

                   <action type="Rewrite" value="{SERVER_NAME}/{LOCAL_ADDR}" />

               </rule>

# April 8, 2011 11:53 AM

OWScott said:

Hi Mikhail,

Great comment and install instructions!  I think we're on the same wavelength.  My next video session covered that same solution: weblogs.asp.net/.../url-rewrite-outbound-rules-and-servernamevariable-part-14-of-52.aspx

I explain an add-on to provide the server name.  

The {SERVER_NAME} variable is the website name and not the actual machinename, unfortunately, otherwise that would be the ideal solution.  If you rewrite the {SERVER_NAME} at the local balancer than it could work.  

{LOCAL_ADDR}, on the other hand, should be specific to each node, which avoids the provider that I offered.  The provider gives the full machine name, which is a bonus, but {LOCAL_ADDR} can do the trick.

# April 8, 2011 12:45 PM

Mikhail Petrovskikh said:

Thank you for the tip Scott! Great video!

In my previous comment I included a small fragment of our deployment documentation that I wrote for our admins, so it was a little verbose :) The {SERVER_NAME} variable was the best solution I could find a few months ago. Maybe IIS team will add the machine name variable eventually until then we will be using your awesome ServerNameVariableProvider. {SERVER_NAME} works well though in many corporate intranet web farm scenarios' when all applications (like in our case) are running under a single default "catch-all" IIS site and load balancer sends all requests to the nodes using their machine names. Usually I add machine name as an X header when I set up a new IIS server like this:

appcmd set config  -section:system.webServer/httpProtocol /+"customHeaders.[name='X-Responding-Host',value='%COMPUTERNAME%']" /commit:apphost

But with Microsoft Web Farm framework that does not work because it replicates configuration among the nodes so I had to use URL Rewrite.

I'm also a big fan of URL Rewrite and ARR, I wish they were better documented :) - many thanks for bloging about it, much appreciated!

# April 8, 2011 4:28 PM

OWScott said:

Hi Mikhail,

I'm with you.  Hopefully the machine name becomes a supported variable available to URL Rewrite in the future.

Also, setting the custom header as you suggested would work perfectly except that the config is fully shared (as you pointed out).  You could replicate with something like robocopy or msdeploy and transform it on the way through, but that feels too much like IIS6.  

Environment variables are supported for some paths and fields within the config, but it wouldn't apply to the URL Rewrite settings.

So, that leaves us with the solutions that you and I have already implemented, with the hopes of other options in the future.

# April 8, 2011 10:26 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)