In layer 2 switching, the Ethernet frames should be received from the same port where it was sent, otherwise layer 2 switching or switching loop occurs.
Let me explain this concept with the topology depicted below (Figure -1).
Figure -1 VLAN load balancing
In the above figure, either Port 1 or Port2 is used to send the traffic, and the same port should be used to receive the traffic. The switches use MAC addresses to process the Ethernet frames.
The switch cannot see the same MAC address from two different ports. In other words, Switch 1 cannot receive the same MAC address from both Port 1 and Port 2.
In order to resolve this problem, both ports can be placed in a bundle. In standard terms, we can link aggregation group (LAG) with the vendor terms, Etherchannel, or port channel.
Since Switch 1, instead of LAG, in the above topology is connected to two different switches (Switch 2 and Switch3), MLAG (Multi Chassis Link Aggregation Group) or MEC (Multichassis Etherchannel) are created between the switches.
On the other hand, spanning tree solves the problem by bringing down one of the ports. If the frame is sent by Port 1, Port 2 is disabled.
Spanning tree carries out its full operation by starting to choose the root switch. The rule is that one of the switches is elected as root switch, and all the ports of root switch are always forward. Thus, the ports moving to the root switch or coming from the root switch cannot be blocked.
In the above topology, if Switch 2 is elected as root bridge (manually by the administrator or dynamically based on smallest MAC address), Switch 3 is used as the backup-root switch. However, if Switch 2 fails, Switch 3 takes full responsibility of the operation.
When Switch 2 is elected as the root switch, Switch 1 to Switch 3 link is disabled by the spanning tree (So, physically UP but layer 2 down).
If there are multiple VLAN in the network, using Port 1 of the Switch 1 to Switch 2 links for some VLANs and Port 2 of the Switch 1 to Switch 2 for the other VLANs can accommodate all the available links in the network. This process is called VLAN based load balancing.
To say it another way, all the ports of the root switch have to be up from the spanning tree point of view; thus, Switch 1 to Switch 3 is blocked to eliminate loop. So, how would VLANs Switch 1 to Switch 3 link be used?
As you can guess, we would assign a root switch role to different switches in that case.
Switch 2 would be the root switch for some set of VLANs, and Switch 3 would be the root switch for other VLANs. They would also be backup root switch for one another.
There are many spanning tree implementations: namely, CST (Common Spanning Tree), PVST (Per VLAN Spanning Tree), RSTP (Rapid Sapannign Tree), RPVST (Rapid Per VLAN Spanning Tree), and MST (Multiple Spanning Tree).
CST is an IEEE standard spanning tree implementation commonly known as 802.1d, and it doesn’t allow different root switches for different VLANs. Put simply, it doesn’t support more than one instance; thus all the VLANs in the network have to be assigned to the same root switch.
PVST, RPVST, and MST support VLAN based load balancing. So, different VLANs can be assigned to different root switches. RSTP, also known as 802. 1w, doesn’t provide VLAN based load balancing.
As you can guess from their names, the difference between RSTP and RPVST is; RPVST (Rapid Per VLAN Spanning Tree) allows VLAN load balancing.