What is Anycast?
Not sure what Anycast is? Try this analogy: It’s day one of your conference in an unfamiliar downtown. You scurry out of your burrow to hunt for the perfect morning brew. You open Google Maps, type coffee, and, like magic, hop to the closest coffee shop without first knowing the specific address of any shop.
It’s like every coffee shop in the world has a single address called coffee, and Google Maps simply routes you to the nearest one. Similarly, in an Anycast network, all servers share the same IP address, and the closest server gives you a coffee…website. After all, isn’t a web server just a bit barista?
Anycast is part of the Border Gateway Protocol (BGP), which is the backbone of the internet that routes network traffic to the nearest resource. In our introductory analogy, BGP is like Google Maps. Devices can use Anycast on both IPv4 and IPv6 networks.
How does Anycast work compared to other IP routing
Compared to Anycast, there are several other IP routing schemes that are better for other use cases.
Unicast is a one-to-one association between a source and a destination, where each device uses a unique address.
Broadcast is a one-to-all association where one device messages all devices in the network.
Multicast is a one-to-many or many-to-many association where a specific set of devices are interested in receiving the messages.
Figure 1: Anycast servers using the same IPs versus Unicast servers using different IPs.
Common use cases for Anycast
Although there are many use cases for Anycast networks, the common use cases include Content Delivery Networks (CDNs), Domain Name System (DNS), Distributed Denial of Service (DDoS) protection, and the Internet of Things (IoT).
CDN
A CDN, like bunny.net, can cache the same content on different servers around the world.
For example, if you live in Australia and want to download a mobile game, Anycast directs you to the nearest server in Sydney to avoid slow download speeds from servers with higher latency due to their distance. However, the fastest connection is not always the closest geographically.
Bunny doesn’t use Anycast for its CDN services; instead, it uses GeoIP. Learn more about the difference between Anycast and GeoIP.
DNS
DNS allows people to browse the internet by typing in domain names like bunny.net in their web browser instead of typing numeric IP addresses. DNS servers resolve these domains to the actual IP addresses networks use to connect. Typically, DNS uses clusters of servers and Anycast to create redundancy if a local DNS server is down.
Bunny uses Anycast for DNS. Additionally, Bunny uses the Extension Mechanisms for DNS (EDNS) to ensure clients get the IP address of the closest Bunny CDN. This helps avoid cases where the IP address of a Bunny CDN that is far from where the client is actually located is provided when a client’s Internet Service Provider (ISP) uses a DNS resolver far from the actual DNS client.
Not all DNS servers on the internet support EDNS.
DDoS protection
Any website served from a single server is vulnerable to DDoS attacks. In a DDoS attack, bad actors exhaust a website with fake traffic to stop legitimate user access. Anycast reduces the impact of DDoS attacks by distributing traffic across multiple servers. An attacker cannot overwhelm a single physical server since many servers all listen for traffic destined for the same IP address. This allows legitimate traffic to proceed and limits malicious impact on a site's availability.
IoT
With the Internet of Things, smart devices need access to servers. Anycast helps them reach the best, usually the closest, server.
How Anycast benefits users
When a website is cached on multiple CDN servers, Anycast routes users to the closest servers. This speeds up website experiences since network requests don't need to travel as far to and from the user.
When there is a good physical distribution and proliferation of devices, Anycast lessens the amount of traffic a specific server must handle and improves reliability since multiple servers can share the backend load. Anycast also provides a means of automatic failover if a server is offline. Applications that use Anycast typically monitor server functionality to withdraw announced BGP routes upon server failure.
Conclusion
Anycast is just one method of directing network data to the most appropriate location. Networks that use Anycast reduce the impact of malicious traffic and create more resilient networks. This benefits users because it speeds up websites and reduces the impact of DDoS attacks.