AlgoMaster Logo

Anycast Routing

Low Priority20 min readUpdated July 4, 2026
AI Mock Interview

Practice this topic in a realistic system design interview

A global service may need to answer users in Tokyo, Frankfurt, and São Paulo without sending everyone to one datacenter. Anycast routing is one way to do that.

With anycast, several locations advertise the same IP prefix. The internet then routes each client to one reachable location using BGP, the routing system that connects networks together. There is no central application server choosing the target.

That makes anycast useful for stable global entry points: public DNS resolvers, CDN edges, DDoS scrubbing networks, and API front doors.

The important catch is that anycast is a network-level tool. It does not know whether a server is overloaded, whether a database is slow, or whether the nearest GPU cluster has capacity. And when people say anycast sends users to the "nearest" server, they really mean the best route according to the internet, not always the physically closest datacenter.

This chapter explains how anycast works, where it helps, and where it can surprise you in production.

1. IP Addressing Models

Before anycast makes sense, it helps to compare it with the other common IP delivery models.

Unicast: One Sender to One Destination

Unicast is the normal model for most network traffic. One destination IP address points to one reachable endpoint, or to one load balancer address, in a specific part of the network.

When a browser connects to an application server, it usually uses unicast.

Broadcast: One Sender to Everyone on a Local Segment

Broadcast sends traffic to every host on the local network segment. It is useful for local protocols such as ARP and DHCP. Routers do not forward normal broadcast traffic across the public internet.

Multicast: One Sender to a Group

Multicast sends packets to receivers that joined a multicast group. It is used in some controlled networks for things like media distribution, market data, and infrastructure protocols. It is not how most public web applications reach users.

Anycast: One Address, Multiple Reachable Instances

With anycast, multiple locations advertise the same IP prefix. The client's network picks one path using BGP.

From the client's point of view, there is one address. From the internet's point of view, that address is reachable from many places.

Anycast is often described as routing to the "nearest" server. A better way to say it is: anycast routes to the best BGP path from that part of the internet. That often means low latency, but not always.

The important difference is who makes the first routing decision:

ModelDelivery PatternDecision PointCommon Use
UnicastOne address to one endpointNormal routing to one prefix originWeb traffic, APIs, databases
BroadcastOne sender to all local hostsLocal network segmentARP, DHCP
MulticastOne sender to subscribed receiversMulticast routing and group membershipControlled media or data distribution
AnycastOne address to one of many instancesBGP route selectionDNS, CDN edges, DDoS scrubbing, global entry points

Anycast is different because the routing layer chooses the destination instance. The sender does not choose it, and your application usually does not choose it either.

2. How Anycast Works

Premium Content

This content is for premium members only.