Network Load Balancing in Windows Server 2016

Posted: January 17, 2017 in Windows Server

The Network Load Balancing (NLB) feature distributes traffic across several servers by using the TCP/IP networking protocol. By combining two or more computers that are running applications into a single virtual cluster, NLB provides reliability and performance for web servers and other mission-critical servers.

The servers in an NLB cluster are called hosts, and each host runs a separate copy of the server applications. NLB distributes incoming client requests across the hosts in the cluster.

In this example we’ll create NLB cluster from 2 nodes (nlb1 and nlb2) which will be hosting IIS site

Installing NLB Cluster and IIS roles

invoke-command nlb1,nlb2 {Install-WindowsFeature nlb -IncludeAllSubFeature -IncludeManagementTools}
invoke-command nlb1,nlb2 {Install-WindowsFeature nlb -IncludeAllSubFeature -IncludeManagementTools}

Creating NLB cluster

On any cluster node run following PowerShell command:

New-NlbCluster -InterfaceName ethernet -ClusterName 'iis_cluster' -ClusterPrimaryIP 192.168.0.10 -SubnetMask 255.255.255.0 -OperationMode Unicast

NLB cluster named IIS with IP 192.168.0.10,unicast mode is created

There are following operation modes:

Unicast – Each NLB cluster node replaces its real (hard coded) MAC address with a new one (generated by the NLB software) and each node in the NLB cluster uses the same (virtual) MAC

Multicast – NLB adds a layer 2 MAC address to the NIC of each node. Each NLB cluster node basically has two MAC addresses, its real one and its NLB generated address.

IGMP multicast  ensures that traffic intended for an NLB cluster passes through only those ports serving the cluster hosts and not all switch ports

Adding NLB node:

Add-NlbClusterNode -NewNodeName nlb1 -NewNodeInterface 'Ethernet' -InterfaceName 'Ethernet'

Setting NLB cluster ports and port filtering mode

Filtering modes:

The None option specifies that multiple connections from the same client IP address can be handled by different cluster hosts

The Single Direct traffic to a single host.

Multiple Hosts: Distribute traffic between the Network Load Balancing (NLB) cluster servers.

 

Get-NlbClusterPortRule | Set-NlbClusterPortRule -NewIP 192.168.0.10 -newProtocol tcp -NewStartPort 80 -NewEndPort 80 -newmode multiple

 

Setting load weight

The load weight applies only for the Multiple hosts filtering mode. When using the Multiple hosts filtering mode,the load weight specifies the relative amount of load-balanced network traffic that this node should handle for the associated port rule.
Allowed values range from 0 (zero) to 100. To prevent a host from handling any network traffic, set the load weight to 0 (zero).

Get-NlbClusterNode -NodeName nlb1 | Get-NlbClusterPortRule | Set-NlbClusterPortRuleNodeWeight -LoadWeight 50

Setting NLB node priority

Each cluster host is assigned a unique host priority in the range of 1 to 32, where lower numbers denote higher priorities.
The host with the highest host priority (lowest numeric value) is called the default host. It handles all client traffic for the virtual IP addresses
that is not specifically intended to be load-balanced.
This ensures that server applications not configured for load balancing only receive client traffic on a single host.
If the default host fails, the host with the next highest priority takes over as default host.

This command sets priority 32 for node nlb1

Set-NlbClusterNode -HostName nlb1 -HostPriority 32 -InterfaceName ethernet

 

The Affinity can be set only when Multiple hosts filtering mode is applied.

The Network option specifies that NLB direct multiple requests from the same TCP/IP Class C address range to the same cluster host. Enabling Network affinity instead of Single affinity ensures that clients that use multiple proxy servers to access the cluster have their TCP connections directed to the same cluster host.

Get-NlbClusterPortRule | Set-NlbClusterPortRule  -NewAffinity single
Get-NlbClusterNode -NodeName nlb1 | fl * 
Invoke-Command nlb2 {get-nlbclusternode -NodeName nlb2 | fl * }

2.png

Because nlb2 has highest priority (1) requests are redirected this node

Test NLB:

on nlb1:

del C:\inetpub\wwwroot\iisstart.htm
echo "This page is hosted on nlb1 node :-)" > C:\inetpub\wwwroot\index.html

On nlb2:

del C:\inetpub\wwwroot\iisstart.htm
echo "This page is hosted on nlb1 node :-)" > C:\inetpub\wwwroot\index.html

 

 

3.PNG

Stop nlb2 node from nlb1

 

Invoke-Command nlb2 {Stop-NlbClusterNode -HostName nlb2}

 

4.PNG

Advertisements
Comments
  1. sheikvara says:

    Reblogged this on Cloud & Virtualization and commented:
    Valuable Article

    Like

  2. wayne says:

    Good post. I tried the same way however it doesn’t work. I have setup the unicast with 2 nics each nlb server with IIS role. Nlb-bound nic is configured with Wan ip as well as cluster ip. Other nic is private ip without default gateway. Those nlb node can ping each other and access web site but no from outside. My setup is straightforward, anything need to be done one external router? Pls advise..

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s