BGP for the AI Era: Multi-Region Routing for Inference Workloads
Design BGP and anycast routing for multi-region AI inference, tying route health to inference SLOs, regional GPU capacity, and predictable failover.
If you have run global web traffic, multi-region routing looks like a solved problem. Then you put a GPU inference cluster behind the same design, and the assumptions start to fail one at a time. BGP multi-region routing for inference workloads looks like the CDN playbook at first glance, but the failure modes are different and mistakes cost a lot more.
Here is the architecture I’d use to keep inference latency predictable across regions without turning the network team into a full-time incident desk. I assume that you already know BGP basics: AS numbers, path attributes, eBGP/iBGP. So, this post is about applying them to a workload that doesn’t tolerate sloppy convergence.
The problem: why inference traffic breaks web routing assumptions
Generic web traffic is forgiving. An extra 200ms because a request landed in the wrong region is often barely noticed, and a stateless HTTP GET is easy to retry somewhere else. Inference traffic is harder, for four reasons.
The first is tighter latency SLOs. A p99 target of 300-500ms end-to-end for a real-time inference call leaves almost no room for a routing detour. Cross-continental round trips alone can burn half that budget before a single token comes back. A web app can hide 150ms behind a spinner. With an inference API it goes directly into the response time that user sees.
The second is what a stall costs you. On a web tier, a request waiting behind a slow or overloaded node blocks a cheap CPU worker. Here you can have a $30,000+ accelerator sitting idle while it could be serving other requests. Send traffic into a saturated region and, on top of the latency, you waste the most expensive compute in the stack. At that price I’d treat capacity-aware routing as cost control.
Then there is regional capacity, which comes in lumps. You can autoscale a web tier from 10 to 200 pods in minutes. GPUs come in expensive, supply-constrained chunks, and a region that runs hot often can’t start more on demand. So routing has to look at where the capacity exists as well as at where latency is lowest.
Finally, failover has to be fast and clean, and eventual consistency is not enough. DNS-based failover depends on clients respecting TTLs, and they often don’t. Resolver caching, sticky client pools and long-lived streaming connections all get in the way. An inference session in the middle of a token stream can’t be retried as cleanly as a stateless page load. If a region degrades, I want the network layer to redirect new connections in seconds. Minutes is too slow.
The natural answer is anycast plus BGP: announce the same service IP from multiple regions and let internet routing pick the path. The goal is the closest healthy region. It works only if you engineer the failure paths as carefully as the happy path.
Reference architecture: BGP multi-region routing for inference clusters
The design is a shared anycast VIP announced from edge routers in each region, with a GPU cluster behind it in every region. A health agent ties the BGP advertisement to real inference SLO metrics rather than to process liveness alone.
Health state feeds directly into route advertisement. A failed ping is not enough to take a region down. The health agent decides that the inference SLO is breached, and this decision withdraws the route.
Decision criteria: anycast + BGP vs GeoDNS vs global load balancer
Firstly, check that BGP is not overkill for you.
| Criteria | Anycast + BGP | GeoDNS | Managed Global L7 Load Balancer |
|---|---|---|---|
| Steady-state latency | Best, routed at the network layer, no resolver hop | Good, depends on resolver geo-accuracy | Good, comparable if the provider has dense PoP coverage |
| Failover speed | Seconds to tens of seconds, depending on how fast the withdrawal propagates | Minutes, bounded by TTL and resolver caching behavior | Seconds to tens of seconds, provider-dependent |
| Blast radius of a bad regional deploy | Contained, if health checks and withdrawal logic are correct; a misconfigured route-map can leak globally | Contained, bounded by TTL | Contained, provider manages isolation |
| Operational complexity | High: own AS, peering relationships, route-map/community discipline, BFD tuning | Low to medium | Low: you trade control for simplicity |
| Cost | Predictable transit/peering + engineering time | Low, mostly DNS query cost | Pay-per-request/data processed; can get expensive at inference-scale egress volumes |
| Client behavior dependency | None, works regardless of resolver or client caching | High, depends on clients respecting TTLs | Low, provider anycast, but still DNS-fronted in most implementations |
| Best fit | High-QPS, strict p99 SLOs, teams with real network engineering capacity | Simple regional failover, small teams, no in-house BGP expertise | Teams that want managed simplicity and can tolerate the cost/control trade-off |
My rule of thumb: if you don’t already run BGP for something else in production, don’t stand up your first AS just for an inference product. Start with a managed global load balancer or GeoDNS. Move to anycast + BGP when query volume and SLO tightness justify the operational overhead. If you already own an AS and edge peering, I’d usually put inference traffic into that fabric. The marginal cost is low and the failover speed is hard to beat.
BGP configuration: communities, health-triggered withdrawal, and BFD
Here is a representative FRR config for an edge router in us-east-1. It announces the shared anycast VIP only while local health is good. BFD is there for fast peer failure detection, and communities carry regional signaling to upstream/transit.
! FRR bgpd.conf - us-east-1 edge router router bgp 65001 bgp router-id 10.10.1.1 no bgp ebgp-requires-policyneighbor 203.0.113.1 remote-as 64500 neighbor 203.0.113.1 description TRANSIT-1 neighbor 203.0.113.1 bfd neighbor 203.0.113.1 bfd profile fast
neighbor 203.0.113.5 remote-as 64500 neighbor 203.0.113.5 description TRANSIT-2 neighbor 203.0.113.5 bfd neighbor 203.0.113.5 bfd profile fast
address-family ipv4 unicast redistribute connected route-map ANYCAST-HEALTH aggregate-address 198.51.100.0/24 summary-only neighbor 203.0.113.1 route-map SET-REGION-COMMUNITY out neighbor 203.0.113.5 route-map SET-REGION-COMMUNITY out exit-address-family ! bfd profile fast detect-multiplier 3 transmit-interval 150 receive-interval 150 exit ! ! redistribute connected advertises the VIP only while its loopback ! (connected) address exists. The health agent removes that loopback ! address on SLO breach. The /24 aggregate needs that /32, so bgpd withdraws ! the /24 from every eBGP peer. Transit networks generally don’t accept IPv4 ! prefixes longer than /24, so the /24 is dedicated to this anycast service. route-map ANYCAST-HEALTH permit 10 match ip address prefix-list ANYCAST-VIP ! route-map SET-REGION-COMMUNITY permit 10 match ip address prefix-list ANYCAST-AGGREGATE set community 65001:100 65001:910 additive ! ip prefix-list ANYCAST-VIP seq 5 permit 198.51.100.10/32 ip prefix-list ANYCAST-AGGREGATE seq 5 permit 198.51.100.0/24
The 65001:910 community is an internal signal. In this scheme, 9xx communities mark region priority tiers that a route-reflector or upstream policy can act on. For example, it can de-prefer a region with reduced GPU capacity without withdrawing it entirely. BFD at 150ms/×3 gives sub-second peer failure detection. Default BGP hold timers (180s) are far too slow for an inference SLO measured in hundreds of milliseconds.
The health agent itself is a small, boring script, and I want it that way. Clever code doesn’t belong here:
# health-agent.sh: runs every 2s via systemd timer on each edge router.
# Ties the BGP-advertised anycast VIP to actual inference SLO health,
# not just "is bgpd running."
# Withdraws after 3 bad probes in a row, announces again after 5 good ones.
# A missing or malformed metric counts as a bad probe.
# It doesn't drain the load balancer: see the pitfalls below.
VIP=198.51.100.10/32
STATE=${STATE:-/run/health-agent.state}
BAD=0; GOOD=0
[ -r "$STATE" ] && read -r BAD GOOD < "$STATE"
P99_MS=$(curl -sf -m 1 http://localhost:9100/metrics/p99_inference_latency_ms)
QUEUE_DEPTH=$(curl -sf -m 1 http://localhost:9100/metrics/gpu_queue_depth)
number='^[0-9]+([.][0-9]+)?$'
if [[ $P99_MS =~ $number && $QUEUE_DEPTH =~ $number ]] &&
awk -v p="$P99_MS" -v q="$QUEUE_DEPTH" 'BEGIN { exit !(p <= 250 && q <= 500) }'; then
GOOD=$((GOOD + 1)); BAD=0
else
BAD=$((BAD + 1)); GOOD=0
fi
echo "$BAD $GOOD" > "$STATE"
if [ "$BAD" -ge 3 ]; then
ip addr del "$VIP" dev lo 2>/dev/null
logger -t health-agent "WITHDRAWN region=us-east-1 p99=${P99_MS:-none}ms queue=${QUEUE_DEPTH:-none}"
elif [ "$GOOD" -ge 5 ]; then
ip addr add "$VIP" dev lo 2>/dev/null
logger -t health-agent "HEALTHY region=us-east-1 p99=${P99_MS}ms queue=${QUEUE_DEPTH}"
fi
The pattern is to redistribute a connected loopback address into BGP, then let a health agent add or remove that address. It keeps the failure domain small. If the health agent crashes, the route stays in whatever state it was last in, instead of flapping unpredictably. The opposite risk is that all regions withdraw at once, for example after a bad metrics change rolled out everywhere. So alert on it, and keep a manual way to announce one region again.
Pitfalls and what I’d do in production
BGP dampening will punish a flapping health check. If your health agent withdraws and re-announces every time a metric crosses a threshold, upstream route flap dampening (RFC 2439-style) can suppress your prefix for 30-60 minutes, long after the region recovered. I’d require N consecutive bad probes before withdrawal and a longer streak of good probes before re-announcing (I’d start with 3 bad / 5 good over a rolling window). Also ask your transit providers if they still apply dampening to customer-originated prefixes. Many have disabled it, but not all. RFC 7196 is the one to read here.
Global convergence is slower than your local withdrawal. Your edge router can pull the route in milliseconds, but propagation in the internet can take tens of seconds, especially during path hunting. If your client-facing timeout is 2-5 seconds, some in-flight and new requests will still land on the degraded region during that window. I’d treat BGP withdrawal as capacity steering, because it doesn’t guarantee that any single request succeeds. Pair it with LB-level connection draining and a client SDK that retries against a secondary regional endpoint on failure. BGP should not be your only line of defense.
MED and AS-path prepending are weaker levers than they look. MED is normally compared only between routes from the same neighboring AS and is non-transitive. Plenty of transit providers ignore or reset it entirely, so don’t rely on it for cross-provider steering. AS-path prepending is coarse, and you can’t guarantee how every downstream AS weighs path length against local policy. So “symmetric” traffic engineering built on prepending can break asymmetrically during partial outages: one direction reroutes cleanly, the other doesn’t, and you get latency degradation on returning traffic that’s hard to diagnose. I’d use LOCAL_PREF for steering when you control both ends (iBGP between owned regions or DCs), because there the result is deterministic. Inter-AS prepending and communities are only hints.
Health checks need to understand inference as well as liveness. A GPU node can be “up” (process healthy, port open) and still fail at its actual job. For example, the model is not loaded, the request queue is backed up from a traffic burst, or thermal throttling reduces throughput. Instead of a synthetic ping, I’d feed the health agent real SLO telemetry: p99 latency, queue depth, GPU utilization and temperature, model load state.
The order of withdrawal matters too. If you pull the BGP route before draining the load balancer, you cut streaming inference sessions mid-token. I’d drain new connections at the LB first, let existing sessions finish or hit their natural timeout, then withdraw the route. Before you mark the region fully out of rotation, verify that the withdrawal propagated (check a couple of external looking-glass vantage points). Also audit graceful-restart / GR-helper configuration on your edge routers. It exists to survive planned bgpd restarts without dropping sessions, but misconfigured GR timers can leave a withdrawn region’s routes looking valid to peers longer than intended.
References
The protocol specifications and the FRRouting manual describe the mechanisms behind this design. Validate timers, route policy and health-agent behavior against the release you run.
- RFC 4271: BGP-4. Reachability advertisements, path attributes, and route withdrawal.
- RFC 5880: Bidirectional Forwarding Detection. Detecting forwarding-path failures independently of application health.
- FRRouting BGP manual. Neighbor configuration, route maps, redistribution, and BGP policy controls.
Related reading
- Networking: the full pillar on routing architecture for modern infrastructure
- Networking: networking design specifically for AI/ML workloads
- Multi-Region Connectivity for Distributed GPU Clusters: coming soon, private backbone and inter-region transport design for training and inference
- IPv6 at Enterprise Scale: A Migration Playbook: dual-stack, a real address plan, and NAT64/DNS64 for IPv6-only GPU fabrics
Let’s talk routing
If you’re designing multi-region routing for an inference platform and want a second opinion, I’m happy to compare notes. Connect with me on LinkedIn or reach out via Contact.