Find which load-balanced server you're on (.NET only)

| | Comments (2)
lost-and-found.jpg

When you're working with servers behind a load balancer, do you ever feel a bit lost about which server you're really on? I do. With the ALUI/WCI portal pages, you can find an HTML comment telling you which server rendered the page. But today I realized it's hard to know which imageserver I'm on. So here's a little file to put on each website. Place it at http://myhostname/whereami.aspx, and you can hit it whenever you want to know which physical server you've been routed to by the load balancer.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Machine: <%= System.Net.Dns.GetHostName() %>
- URL: <%= Request.Url.Host.ToString() %></title>
</head>
<body>
This is machine <b> <%= System.Net.Dns.GetHostName() %></b>.
<p>You came here on URL <b> <%= Request.Url.Host.ToString() %>.</b>
</body>
</html>

This would be simple in Java too, but I've not written it. Add it as a comment if you'd like?

Enjoy!

2 Comments

I've always been under the impression that whatever load balanced server you were on would be using the same image server! Good to know that isn't the case necessarily!

Geoff, in your environment the situation you describe may be correct. If you have the portal and the imageserver both on the same host (e.g. http://www.company.com/portal and http://www.company.com/imageserver) and if the you install both the portal and imageserver on the same boxes, then the routing for the portal will tell you about the imageserver's routing too.

In the environment I'm working in, we have separate boxes for the portal and the imageserver. Further, we have different hosts (e.g. http://app.company.com/portal and http://img.company.com/imageserver). Thus, the portal's routing will never help us know what imageserver we're on.

Thanks as always for your comments.

Leave a comment