Contents

Introduction

Prerequisites

Requirements

Components Used

Conventions

Background Information

Load Balancing

Per-Destination and Per-Packet Load Balancing

Related Information

Introduction

This document describes how load balancing works in the functionality of router software and platforms.

Prerequisites

Requirements

There are no specific requirements for this document.

Components Used

This document is not restricted to specific software and hardware versions.

The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, ensure that you understand the potential impact of any command.

Conventions

For more information on document conventions, refer to Cisco Technical Tips Conventions.

Background Information

Load balancing is a standard functionality of the Cisco IOS® router software and is available across all router platforms. It is inherent to the forwarding process in the router and is automatically activated if the routing table has multiple paths to a destination. It is based on standard routing protocols, such as Routing Information Protocol (RIP), RIPv2, Enhanced Interior Gateway Routing Protocol (EIGRP), Open Shortest Path First (OSPF), and Interior Gateway Routing Protocol (IGRP), or derived from statically configured routes and packet forwarding mechanisms. It allows a router to use multiple paths to a destination when forwarding packets.

Load Balancing

When a router learns multiple routes to a specific network via multiple routing processes (or routing protocols, such as RIP, RIPv2, IGRP, EIGRP, and OSPF), it installs the route with the lowest administrative distance in the routing table. Refer to Route Selection in Cisco Routers for more information.

Sometimes the router must select a route from among many learned via the same routing process with the same administrative distance. In this case, the router chooses the path with the lowest cost (or metric) to the destination. Each routing process calculates its cost differently and the costs sometimes need to be manipulated in order to achieve load balancing.

If the router receives and installs multiple paths with the same administrative distance and cost to a destination, load balancing can occur. The number of paths used is limited by the number of entries the routing protocol puts in the routing table. Four entries is the default in Cisco IOS for most IP routing protocols with the exception of Border Gateway Protocol (BGP), where one entry is the default. Six different paths configured is the maximum number.

The IGRP and EIGRP routing processes also support unequal cost load balancing. You can use the variance command with IGRP and EIGRP to accomplish unequal cost load balancing. Issue the maximum-paths command in order to determine the number of routes that can be installed based on the value configured for the protocol. If you set the routing table to one entry, it disables load balancing. Refer to How Does Unequal Cost Path Load Balancing (Variance) Work in IGRP and EIGRP? for more information about variance.

You can usually use the show ip route command to find equal cost routes. The next example is the show ip route command output to a particular subnet that has multiple routes. Notice there are two routing descriptor blocks. Each block is one route. There is also an asterisk (*) next to one of the block entries. This corresponds to the active route that is used for new traffic. The term 'new traffic' corresponds to a single packet or an entire flow to a destination, based on the type of switching configured.

- For process-switching — load balancing is on a per-packet basis and the asterisk (*) points to the interface over which the next packet is sent.

- For fast-switching — load balancing is on a per-destination basis and the asterisk (*) points to the interface over which the next destination-based flow is sent.

The position of the asterisk (*) continues to rotate among the equal cost paths each time a packet/flow is served.

M2515-B#show ip route 10.0.0.0

Routing entry for 10.0.0.0/8

Known via "rip", distance 120, metric 1

Redistributing via rip

Advertised by rip (self originated)

Last update from 192.168.75.7 on Serial1, 00:00:00 ago

Routing Descriptor Blocks:

* 192.168.57.7, from 192.168.57.7, 00:00:18 ago, via Serial0

Route metric is 1, traffic share count is 1

192.168.75.7, from 192.168.75.7, 00:00:00 ago, via Serial1

Route metric is 1, traffic share count is 1

Per-Destination and Per-Packet Load Balancing

You can set load balancing to work per-destination or per-packet. Per-destination load-balancing means the router distributes the packets based on the destination address. Given two paths to the same network, all packets for destination1 on that network go over the first path, all packets for destination2 on that network go over the second path, and so on. This preserves packet order, with potential unequal usage of the links. If one host receives the majority of the traffic all packets use one link, which leaves bandwidth on other links unused. A larger number of destination addresses leads to more equally used links. To achieve more equally used links use Cisco IOS software to build a route-cache entry for every destination address, instead of every destination network, as is the case when only a single path exists. Therefore, traffic for different hosts on the same destination network can use different paths. The downside of this approach is that for core backbone routers that carry traffic for thousands of destination hosts, memory, and processing requirements to maintain the cache becomes a challenge.

Per-packet load balancing means that the router sends one packet for destination1 over the first path, the second packet for (the same) destination1 over the second path, and so on. Per-packet load balancing guarantees equal load across all links. However, there is potential that the packets can arrive out of order at the destination because differential delay can exist within the network. In Cisco IOS software, except the release 11.1CC, per packet load balancing does disable the forwarding acceleration by a route cache, because the route cache information includes the outgoing interface. For per-packet load balancing, the forwarding process determines the outgoing interface for each packet when it looks up the route table and picks the least used interface. This ensures equal utilization of the links but is a processor intensive task and impacts the overall forwarding performance. This form of per-packet load balancing is not well suited for higher speed interfaces.

Per-destination or per-packet load balancing depends on the type of switching scheme used for IP packets. By default, on most Cisco routers, fast switching is enabled under interfaces. This is a demand caching scheme that does per-destination load balancing. To set per-packet load-balancing, enable process switching (or disable fast switching), use these commands:

Router#configure terminal

Router(config)#interface Ethernet 0

Router(config-if)#no ip route-cache

Router(config-if)#^Z

Now the router CPU looks at every single packet and load balances on the number of routes in the routing table for the destination. This can crash a low-end router because the CPU must do all the processing. To re-enable fast switching, use these commands:

Router#configure terminal

Router(config)#interface Ethernet 0

Router(config-if)#ip route-cache

Router(config-if)#^Z

Newer switching schemes such as Cisco Express Forwarding(CEF) allow you to do per-packet and per-destination load-balancing more quickly. However, it does imply that you have the extra resources to maintain CEF entries and adjacency.

When you work with CEF, you could ask: Who does the load balancing, CEF or the routing protocol used? The way in which CEF works is that CEF does the switching of the packet based on the routing table which is populated by the routing protocols such as EIGRP. In short, CEF performs the load-balancing once the routing protocol table is calculated.

Refer to Troubleshooting Load Balancing Over Parallel Links Using Cisco Express Forwarding and Load Balancing with CEF for more information about CEF load balancing.

These next documents provide more information about how various protocols select a best path, calculate their costs to specific destinations, and how they perform load balancing when applied.

- IGRP Metric - Example and Explanation

- Setting a Preferred Route by Influencing EIGRP Metrics

- OSPF Cost

- BGP Path Selection Algorithm - This document explains how to use BGP multipath. BGP multipath allows multiple BGP paths to the same destination to be installed in the IP routing table together with the best path for load-sharing.

Related Information

- Load Balancing with CEF

- Troubleshooting Load Balancing Over Parallel Links Using Cisco Express Forwarding

- IP Routing Support Page

- Cisco Technical Support & Downloads