← Lessons

quiz vs the machine

Platinum1800

System Design

Locality Aware Routing

Keeping traffic close to home for lower latency while failing over across zones.

5 min read · advanced · beat Platinum to climb

Distance Costs Latency and Money

In a multi zone or multi region deployment, calling a far endpoint adds latency and often cross zone data charges. Locality aware routing prefers nearby endpoints, sending traffic to the same zone first.

The Locality Hierarchy

The mesh understands a hierarchy: region, then zone, then subzone. A proxy prefers the closest tier that has healthy capacity and only spills over to the next tier when needed.

  • Same zone is cheapest and fastest.
  • Same region, different zone is a reasonable fallback.
  • Cross region is the last resort.

Failover Without Losing Locality

The key trick is weighted failover with health awareness. If local endpoints are healthy, all traffic stays local. As local endpoints fail or fill, the mesh gradually shifts a proportion of traffic outward, so you keep the latency benefit until the moment locality can no longer serve.

The Balance

Pure locality risks overloading a small zone. Pure round robin wastes latency. Locality aware routing blends them, favoring closeness while guaranteeing availability through controlled failover.

Key idea

Locality aware routing prefers same zone endpoints for low latency and cost, then fails over by region and zone only as local capacity degrades, balancing closeness against availability.

Check yourself

Answer to earn rating on the learn ladder.

1. What does locality aware routing prefer?

2. When does locality aware routing send traffic across regions?