AS-path length is a bad proxy for latency
BGP picks the shortest path in hops, which has almost nothing to do with the shortest path in milliseconds.
There is a comfortable assumption in network design that fewer autonomous systems in the path means a faster path. It is intuitive, it is easy to explain to management, and it is wrong often enough to matter.
What BGP is actually optimising for
The best-path algorithm walks a fixed list of tie-breakers: highest local preference, shortest AS path, lowest origin type, lowest MED, eBGP over iBGP, lowest IGP cost to the next hop, oldest route, lowest router ID. Notice what is absent. There is no latency term, no loss term, no capacity term. AS-path length sits second on the list precisely because it is cheap to compute and guarantees loop freedom - not because it correlates with performance.
A path is a sequence of administrative domains, not a sequence of physical hops. One AS in the path might be a single router in the same building. Another might be a network that carries your packet from Frankfurt to Ashburn and back to Amsterdam because that is where its capacity happens to be.
Three ways a short path is a slow path
1. Hot-potato routing
Most networks hand traffic off at the nearest exit to their own network, not the nearest exit to the destination. If your two-AS-hop provider hands your Frankfurt-to-Munich traffic to a peer in Amsterdam because that is their closest interconnect, you have paid for two extra crossings of the continent to save one AS in the path.
2. Congestion is invisible to BGP
A peering link running at 97% utilisation during the evening peak looks exactly like an empty one from the control plane's point of view. The route stays up, the AS path stays short, and your p99 latency triples between 20:00 and 23:00. Nothing in BGP notices, and nothing in BGP will move the traffic for you.
3. Physical geography ignores administrative geography
The shortest AS path from a European network to a South American one may traverse a single large carrier - who routes it via North America because that is where the cables land. A longer path through a network with a direct South Atlantic cable is fewer milliseconds and more AS hops.
What to measure instead
Path quality is an empirical question. Measure it:
- Per-destination RTT from your edge, sampled continuously rather than during a maintenance window. Aggregate by destination ASN so you are looking at networks, not addresses.
- Loss and jitter at peak, not average. A path that is perfect at 04:00 and lossy at 21:00 is a bad path.
- Per-provider comparison for the same destination. If you are multi-homed you already have the experiment set up; you just have to run it.
Once you have that data, AS-path length becomes what it should be: a tie-breaker of last resort.
The levers that actually work
Local preference
Local preference is evaluated before AS-path length, which makes it the correct tool. Set it per provider, per destination region, or per destination ASN. A provider community that raises localpref for a specific continent will beat a shorter path every time.
Selective advertisement
Inbound traffic is harder because you do not control the remote decision, but you influence it. Announcing a more specific prefix through the provider you want inbound traffic on beats every other tie-breaker, because longest-prefix match happens before best-path selection runs at all. Use it sparingly - the global table does not need your /24s split into /25s.
Prepending, carefully
AS-path prepending is the blunt instrument. It works, but it works globally and unpredictably: you cannot know which remote networks weight AS-path highly enough for your prepend to matter. Prefer per-region prepend communities where your provider offers them.
What we do about it
Our route policy is fed by continuous active measurement between our own edge nodes and a large sample of destination networks. Where a longer AS path measures materially better, localpref reflects that. This is not exotic - several large carriers do it - but it is worth asking your provider whether they do, and asking to see the data.
The practical takeaway: stop treating a traceroute with fewer AS hops as evidence of a better path. Measure the thing you actually care about, and use local preference to act on what you find.