Many servers share one IP address, and the network sends you to the nearest.
With anycast, many servers in many places share the same IP address. The internetβs routers send each user to the nearest one.
Normally one IP address belongs to one machine. This is unicast. In anycast, the same IP is announced from many places at once. The network (using a protocol called BGP) sends each packet to the closest place, in terms of network path.
Each site tells its neighbouring networks βI can reach 1.2.3.4.β using BGP. Routers collect many such announcements for the same IP. They pick the best path (usually the shortest). So a packet from Paris goes to the site that is closest by network path.
If a site fails or is turned off, it stops announcing the IP (it withdraws the route). Routers forget that path and use the next best one. Health software at the site often does this on its own.
| Type | Who receives it | Example |
|---|---|---|
| Unicast | One specific machine | Your laptop talking to one web server |
| Broadcast | Everyone on a local network | ARP request on your Wi-Fi |
| Multicast | A chosen group | Live video feed to subscribers |
| Anycast | The nearest of a group | Public DNS, CDN edge |
Map is a simple sketch, not to scale. Delay is a made-up number based on distance on the map.
Most teams do not run anycast on their own. They use a provider (a CDN or a cloud global load balancer) that has done it already. If you do it yourself, the steps look like this.
| Term | Meaning in easy words |
|---|---|
| Unicast | One IP belongs to one machine |
| Anycast | One IP is shared by many machines. Traffic goes to the nearest |
| BGP | The protocol that networks use to tell each other which IPs they can reach |
| Route announcement | A message saying βI can reach this IP rangeβ |
| Route withdrawal | Taking that message back, so no traffic comes (used for failover) |
| Edge site / PoP | A small data centre close to users (Point of Presence) |
| ASN | A number that identifies a network on the internet |
| Latency | How long a request takes to travel and return |
| DDoS | An attack that floods a service with traffic |
| Route flap | A route that keeps changing. Can break long connections |
| Choice | We gain | We lose |
|---|---|---|
| Anycast for DNS or short requests | Speed, simple failover | Needs operations skill |
| Anycast for long TCP connections | Nearest site | Risk of resets if routes change |
| Use a provider | No BGP to manage | Less control, lock-in |
| Many small sites | Closer to users, spread attacks | More places to run and update |