Most of the Internet follows a unicast addressing approach in which an IP address links to one particular server, work station, or router. While this logically makes sense, it introduces a single point of failure. Unicast also makes it difficult to optimize services for users in wide geographic areas. For instance, a user in Scotland may have to connect to the same IP address as a user in Canada.
Anycast solves these issues by allowing multiple nodes to share the same IP address. Similar to how emergency calls work on a phone, Anycast takes a connection to a single IP address and resolves it to one of several available nodes (allowing a Scottish user to connect to a UK server and a Canadian user to connect to a North America server).
How Anycast Works
Content providers host web services in several locations around the world. Each location resolves to the same IP address, allowing packets to travel to one or more nodes. When the provider’s routing system comes across an incoming packet, it determines the location closest to the packet and routes the packet accordingly.
Here is an example of how it works step by step:
- A user opens a web page or connects to a web service, creating a connection to a service provider.
- The user’s browser resolves the domain name of the service. Some service providers offer their own domain name resolution servers that use Anycast for low latency DNS resolution.
- The browser connects to the IP address.
- The provider routes the connection to the nearest server to maximize performance.
In addition to improving speed, Anycast offers a way for service providers to handle failures. If a server goes offline, packets are immediately routed to the next available server, providing an uninterrupted experience for users while allowing developers to identify and solves the problem.
Example of Anycast
Assume a user wants to connect to a service that contains assets cached by StackPath. In this scenario, StackPath uses a series of Anycast DNS servers that quickly route and resolve the domain name request. Once the user has the service’s IP address, StackPath routes each request for that IP address to the closest available edge server that can respond to the requests.
StackPath also leverages Anycast when performing upgrades and routine maintenance. Edge servers are taken offline by stopping the announcement of its Anycast IP address, thereby taking it out of the available Anycast pool. Until it’s brought back online, requests are routed to the next closest edge server.
Benefits of Anycast
- Users have a faster, uninterrupted experience as their connections are seamlessly routed to the server closest to them
- Web services experience lower administration costs since Anycast inherently routes around slow or failed nodes
- Web services experience higher customer satisfaction since Anycast prevents users from experiencing slow or unavailable service
While Anycast can be difficult to implement, it has enormous benefits in terms of performance and reliability. Organizations like OpenDNS rely on Anycast to handle over 50 billion DNS queries on a daily basis while maintaining 100% uptime. For services with growing user bases, having a system that can handle failures quickly and transparently is a necessity.