Skip to content

CONCEPT Cited by 1 source

Hairpin routing

Definition

Hairpin routing (in the CDN/caching context) is the pathological traffic pattern where a request is routed to a distant intermediary data center only to have that intermediary fetch content from an origin that was geographically close to the original requester — adding an unnecessary cross-continental round trip.

Canonical Example (Cloudflare)

Say your origin sits in Singapore, behind an anycast IP from a cloud provider. Because of how anycast works, our Chicago data center might show the lowest probe latency to that IP. Smart Tiered Cache would then select Chicago as the upper tier. The result: a request from an end user in Asia hits a nearby Cloudflare data center, gets routed cross-continent to the upper tier in Chicago, and Chicago fetches from the origin back in Singapore, crossing the ocean twice.

The path: Asia edge → Chicago upper tier → Singapore origin — when it should be: Asia edge → Singapore-adjacent upper tier → Singapore origin.

Root Cause

Hairpinning occurs when: 1. The topology selector relies on latency probes to an IP that doesn't represent the actual backend location. 2. Anycast/regional-unicast front-ends make many data centers appear equally "close" to the origin IP. 3. Without true location knowledge, a distant data center may win the latency race against the cloud provider's front-end.

Impact

  • Adds hundreds of milliseconds of unnecessary latency.
  • Wastes backbone bandwidth on redundant cross-continental hops.
  • One of the most consistently reported issues from customers with cloud-hosted origins.

Mitigation

Distinct From

Not to be confused with concepts/hairpin-route-leak (a BGP routing anomaly where a multi-homed AS re-advertises routes from one provider to another). The CDN concept here is about traffic inefficiency within a cache hierarchy, not inter-AS routing policy violations.

Seen in

Last updated · 575 distilled / 1,757 read