Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How Does Network Load Balancing Algorithm Works Internally


Author: Nirmal Sharma MVP

View products that this article applies to.

Summary

This article explains how NLB algorithm works internally form a technical point of view.

↑ Back to the top


More information

General rule for a NLB Cluster which applies to each host in the cluster:

1. All port rules (range) defined in a host cluster must be unique across the cluster.
2. Host priority (Default Host) must be unique across the cluster.
3. Cluster mode must be unique across the cluster: either Unicast or Multicast.

A cluster node maintains a statistical mapping of port rules with associated Virtual IP of the cluster. I will give an port rule example and then explain how it works in cluster when an incoming TCP/IP packet arrives to cluster hosts. I have configured the following port rule at one of the cluster host:

Host 1
Port Range: 80 to 80
Protocol: TCP
Host ID: 1
Filtering Mode: Multiple, Load Weight: 70
Virtual IP 10.0.0.1

Host 2
Port Range: 80 to 80
Protocol: TCP
Host ID: 2
Filtering Mode: Multiple, Load Weight: 30
Virtual IP 10.0.0.1

After configuring port rules on cluster hosts, all the hosts simultaneously invoke a process called �Convergence Process�. The main objective of this process to check any inconsistency in the rule defined for that cluster and also designates a host as the Default Host in case of a host fails to converge successfully. After convergence process has finished all the hosts will maintain a list of statistical mappings in the local computer as portrayed below:

Statistical mapping on Host 1 Counter = 1
Host Name Port Range Protocol Host ID Filtering Mode Load Weight Virtual IP Flag
Host 1 80 To 80 TCP 1 Multiple 70 10.0.0.1 1
Host 2 80 To 80 TCP 2 Multiple 30 10.0.0.1 1

Statistical mapping on Host 2 Counter = 1
Host Name Port Range Protocol Host ID Filtering Mode Load Weight Virtual IP Flag
Host 2 80 To 80 TCP 2 Multiple 30 10.0.0.1 1
Host 1 80 To 80 TCP 1 Multiple 70 10.0.0.1 1

Note: These two hosts are running IIS to host a company web site called CSC.com and this site is mapped to 10.0.0.1 virtual IP Address.

How a host does this internally when a client sends traffic for configured port rule

Let�s take an example: A client running Windows 2000 or XP open up a browser and type the www.csc.com.
  1. Request is forwarded to the cluster IP Address (10.0.0.1).
  2. Cluster receives the traffic at Network Layer where the NLB driver service sits and watches for an incoming packet.
  3. All hosts simultaneously receive this packet and look in its statistical mapping to see if the traffic is covered in the port rules defined or not.
  4. If traffic is covered in the port rule then it checks whether this host has already served or not. The Flag column indicates the status of host whether this host served the last traffic or not. The Flag will be incremented by 1 if this host had served the last traffic. For example: if Host 1 receives the traffic, it will serve the client and then increment the Flag by 1.
  5. In this example, Host 1 receives the packet/traffic and other hosts discard the packet.
  6. If the traffic is not covered by the port rule then the only host will receive the traffic which has been designated as the Default Host. This is identified by the Host ID in statistical mapping.
  7. After Host 1 has served the request the statistical mapping on that host will look like below:

Statistical mapping on Host 1 after serving client Counter = 2

Host Name Port Range Protocol Host ID Filtering Mode Load Weight Virtual IP Flag
Host 2 80 To 80 TCP 2 Multiple 30 10.0.0.1 1
Host 1 80 To 80 TCP 1 Multiple 70 10.0.0.1 2

You notice that Flag value has been incremented by 1 to make sure this host doesn�t receive the next traffic for the configured port rules. This host will service the next traffic only when the Host 2 has served the second request after Host 1.

Please note: There are other things a host consider when receiving the incoming traffic. For example, checking Filtering Mode if configured for a single host or disabled for the configured port rules, Client Affinity, multiple Virtual IP Addresses in a single cluster, Host Priority ID (which is different from Host ID), Mode of the Host (Unicast, Multicast and IGMP), Layer 2 and Layer 3 switch.

↑ Back to the top


Community solutions content disclaimer

Microsoft corporation and/or its respective suppliers make no representations about the suitability, reliability, or accuracy of the information and related graphics contained herein. All such information and related graphics are provided "as is" without warranty of any kind. Microsoft and/or its respective suppliers hereby disclaim all warranties and conditions with regard to this information and related graphics, including all implied warranties and conditions of merchantability, fitness for a particular purpose, workmanlike effort, title and non-infringement. You specifically agree that in no event shall Microsoft and/or its suppliers be liable for any direct, indirect, punitive, incidental, special, consequential damages or any damages whatsoever including, without limitation, damages for loss of use, data or profits, arising out of or in any way connected with the use of or inability to use the information and related graphics contained herein, whether based on contract, tort, negligence, strict liability or otherwise, even if Microsoft or any of its suppliers has been advised of the possibility of damages.

↑ Back to the top


Keywords: KB556068, kbhowto, kbpubtypecca, kbpubmvp

↑ Back to the top

Article Info
Article ID : 556068
Revision : 1
Created on : 3/1/2008
Published on : 3/1/2008
Exists online : False
Views : 397