Wednesday, October 10, 2012

Unicast Network Load Balancing... Reliably

Microsoft Network Load Balancing can be difficult to setup reliably and there are a myriad of better options out there. With that enthusiastic endorsement, I'm writing this guide to walk you through (at a very high level) how to setup unicast clusters reliably.

Assumptions

2008r2 Servers (this should work down to 2k3 but there will be minor differences)

Both hosts are connected to the same switch or vSwitch

You can have at least two NICs per host

1 static IP address per NIC. (i.e. 2 per host)

1 IP for your clustered address

You really want to do this and don't have a better way to split network traffic

Example Network:

In this example, we use the following addresses. Substitute in yours where applicable.

HostA: 192.168.1.5, (IP For Cluster NIC) 192.168.1.6 (IP for Other)

HostB: 192.168.1.7, (IP For Cluster NIC) 192.168.1.8 (IP for Other)

ClusterIP: 192.168.1.22

Steps

Ensure each host has at least two NICs with the appropriate IPs configured. You *can* setup a unicast NLB cluster with one per host, but trust me you don't want to. (unless your app can't handle a multi-homed server)

(Do for each host) Navigate to the advanced TCP/IP settings->DNS tab of the adapter that will participate in the cluster and UNcheck the box "Register this connection's addresses in DNS"

Note: This will ensure that when the machine is looked up by its dedicated individual IP as opposed to the IP used by the cluster adapter which will share a MAC address with the other host.

Open the NLB Manager Administrative Tool and right click the root->New Cluster

Under Host, type the first host you wish to add, click connect, and then select the IP of the adapter that you removed from DNS a couple steps above and click "Next"

Set the priority and default state. Priority is this host's priority in the cluster where a lower number represents a higher priority, and default state represents the participation of this host in the cluster. If you're not sure, take the defaults of 1 and Started. Click "Next"

Click "Add" and put in your Cluster IP address. Click "Next"

On the next "Cluster Parameters" screen, put in the DNS alias you will use for the cluster IP under "Full Internet Name" and set "Cluster operation mode" to "Unicast". Click "Next".

Cluster Params

On the New Cluster: Port Rules you can accept the defaults unless you want to be explicit with your clustered ports. Click "Finish"

Quick note: MS NLB doesn't support automatic failover based on service status, I.E. if the host is responding to any network requests it is assumed to be up even though the service may have failed. That's why I chose to accept the default and host all services on the cluster IP and dedicate a NIC to the task. This has proven to be substantially more reliable. For security, ensure your firewall is active and configured correctly.

Right click the newly created cluster and click "Add host to cluster" and input the second host. Follow the same steps that we did above for this host and exit the wizard.

If you're using VMWare: perform the steps under "Configuring Unicast Mode" listed in this document. This disables the automatic MAC relocation on the vSwitches.

If desired, do a static DNS registration for the "full internet name" of the cluster.

That should do it. Remember that you will have to do fail-over manually in most circumstances.