bgp hints - internet routing news, hints and tips

Posted: 2003-09-17

Category: General

Redundancy and load balancing with anycast

Many hardware and software solutions exist to implement redundancy and load balancing for hosted services. One way to implement load balancing and redundancy is to use anycast, defined in RFC 1546. In an anycast setup, multiple hosts share the same IP address. This address is announced through a routing protocol, so that packets sent to the anycast address will be routed to the (network topology wise) closest host. A paper from Cisco provides a good background on anycast. Another, more theoretical paper is available from IBM.

Because anycast relies only on a routing protocol, no additional hardware or software is needed to implement it. Since it relies on inherently dynamic routing protocols (such as OSPF or BGP) to decide which host packets are routed to, it is generally only useful for protocols that require very little state, such as DNS. According to some, in practice this instability is not significant enough to prevent anycast from being used for TCP-based services.

Several real-world large scale anycast applications exist, mainly in the area of DNS services. Examples include the AS112 nameservers for private IP space, the F root server, and 6to4 routers for providing access to IPv6 space for IPv4 systems. Also, some ISP's are using anycast internally for the DNS servers used by their customers.

Using the open source routing suite Zebra (or its descendant Quagga), it is fairly easy to set up anycast for Unix based hosts. Give each host participating in the anycast network an additional IP address, and announce this to your routers in your network. Traffic will now be sent to the host closest to the client. Since most routers use flow based hasing when deciding between multiple paths of equal cost, even local loadbalancing can be implemented this way.

You should run a script or monitoring program to make sure the service provided by each host is still functioning properly. Should the service fail, the anycast IP address should be withdrawn from the routing protocol. Another thing to keep in mind is in order to facilitate debugging, there should be a way for clients to determine which anycast server they are dealing with. For example, the AS112 servers allow this by returning a server-specific TXT record when resolving hostname.as112.net.

If you have any questions or comments regarding this article, please contact bgp@ruud.org.