Flow-based load balancing is used mostly in layer 2 networks, although in Layer 3 routing, packets can be load balanced per packets or per flow, flow-based load balancing is commonly used with the Local area network, datacenter and datacenter interconnect technologies.
There are two important load balancing mechanisms in layer 2. Vlan-based load balancing and Flow-based load balancing. Understanding the differences of these two is important for network engineers, thus please read Vlan-based load balancing post from here as well.
Load-balancing is probably a wrong term though and load-sharing should be used for stateless devices and I explained the differences between load-balancing and load-sharing here.
Let’s look at below figure to understand flow-based load balancing.
Figure -1 Flow based load balancing with basic switch topology
In figure-1 for the simplicity only three switches are shown. Spanning tree is used to create a layer 2 topology for the ethernet. It is one of the control plane mechanisms for Ethernet. There are others such as SPB (Shortest Path Bridging) , Trill, Fabricpath as well.
In this post, I will use spanning tree as a control plane mechanisms for Figure-1.
Imagine you have 10 Vlans and the Switch2 is root switch for all 10 Vlans.
And in every vlans you have 10s of hosts.
If the link between switch 2 and switch 3 is Layer 3 link, spanning tree doesn’t block any links in this topology. This topology is called then Layer 2 loop-free topology.
Spanning tree deals with the logical layer 2 topology. For the layer 3 part, default gateway purpose, one of the first hop redundancy mechanisms is used. It can be HSRP , VRRP or GLBP.
If HSRP or VRRP is used, one of the switch can be used as a primary for the given Vlan and other switch is used as standby.
Switch 2 for example can be used for Vlan 5 as primary and switch 3 is used as standby for Vlan 5. For another Vlan, for example Vlan 6, switch 3 is used as primary and switch 2 as standby. This allows all the uplinks of switch 1 to be used thus bandwidth is not wasted.
HSRP and VRRP thats why provide Vlan based load balancing. Default gateway for a particular Vlan can be only one of the switches.
If we use GLBP (Gateway Load Balancing Protocol) in this topology, for any given Vlan, both Switch 2 and switch 3 can be used as default gateway. Fo different host which come from the same Vlan, Arp replies are sent by different switches. Switch 2 can be a default gateway of host 1 in Vlan 5 and switch 3 can be a default gateway of host 2 in Vlan 5.
As you can understand, traffic for different set of hosts in the same Vlan can be sent by switch 1 to switch 2 and switch 3 at the same time.
Flow is not described as host of course. For the same host, different destination IP address and port numbers mean different flows.
Then, we can say that some of the traffic of host 1 in Vlan 5 can be sent to Switch 2, and some of the traffic of the same host can be sent to switch 3.