Thursday, October 30, 2008

Testing Server 2008 NLB clusters

I am working on an article for Server Management magazine, due out on December focusing on Clustering. One aspect of this article is around NLB clusters in Server 2008. To test this, I wrote a very simple ASP.Net Application.

Here’s the default.aspx web page:

1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="myip._Default" %> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 3 <html xmlns="" > 4 <head runat="server"> <title>NLB Test on NLB 1Tool</title></head> 5 <body> 6 <form id="form1" runat="server"><div></div> 7 <p> NLB Test Tool</p><p></p> 8 <p> The IP address of this server is:</p> 9 <asp:Label ID="Label1" runat="server"></asp:Label> 10 </form> 11 </body> 12 </html>

As you can see, this ASP.NET has some code:

using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Net; namespace myip { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string strHostName = " "; strHostName = System.Net.Dns.GetHostName(); IPHostEntry ipEntry = System.Net.Dns.GetHostByName(strHostName); IPAddress[] addr = ipEntry.AddressList; Label1.Text = addr[0].ToString(); } } }

I loaded this onto two NLB cluster hosts changing the HTML title on each host to reflect the host name (the HTML avove is used on Node 1)! When I then navigated to the page, I saw this:


As you can seem, in this case, the cluster served up Node 2. Depending on which underlying host serviced the request, I saw a different title and a different IP address.

Thanks for and Naveen K Kohli for the important parts of the C#code.

Technorati Tags: ,,

No comments: