tiered-caching

1 posts

cloudflare

Improving Smart Tiered Cache for public cloud regions (opens in new tab)

Cloudflare’s Smart Tiered Cache efficiently routes cache misses through one optimal upper-tier data center, but anycast and regional cloud origins make latency-based selection unreliable. Smart Tiered Cache for Public Cloud Regions addresses this by using a customer-provided cloud region hint to choose geographically appropriate primary and fallback tiers. The result is better cache efficiency, fewer origin requests, and reduced cross-continent “hairpin” traffic. ## Smarter Tiered Cache Topology - Smart Tiered Cache is available on all Cloudflare plans at no additional cost. - It selects a single upper tier based on real-time latency when an origin has a fixed, unicast IP. - Previous enhancements added support for: - **R2**, selecting an upper tier near the bucket’s actual location. - **Load Balancing**, selecting one tier for an entire pool so origins share cache content. - The new feature extends this approach to public cloud origins hosted on AWS, GCP, Azure, and Oracle Cloud. ## Why Anycast Origins Cause Problems - Anycast and regional unicast IPs represent cloud provider front ends rather than one physical origin location. - Multiple Cloudflare data centers may appear equally close to the same IP, preventing reliable selection of one upper tier. - The wrong selection can cause hairpin traffic. For example, an origin in Singapore might be assigned to an upper tier in Chicago, forcing Asian users’ requests across the Pacific and back. - This can add hundreds of milliseconds, increase origin connections, and reduce cache hit ratios. - Cloudflare detects likely anycast origins by comparing probe latencies against the physical limits imposed by the speed of light. - When anycast is detected without additional information, Smart Tiered Cache safely uses multiple upper tiers instead of pinning traffic to one. ## Configuring a Cloud Region Hint - In the dashboard, go to **Caching > Tiered Cache > Origin Configuration**. - Select an origin IP and choose **Set Region Hint**. - Enter a region such as: - `aws:us-east-1` - `gcp:europe-west1` - Hints can be configured individually or applied in bulk. - The same configuration is available through the API and Terraform. - Dashboard hints are currently available only for IPs Cloudflare has identified as anycast. - The initial release supports AWS, GCP, Azure, and Oracle Cloud, with more providers planned. ## How Region-Based Selection Works - Cloudflare periodically downloads each provider’s current IP range files. - These files map cloud regions to their active IP prefixes, allowing Cloudflare to track subnet changes. - Cloudflare matches those prefixes against an upper-tier database updated through latency probing every 15 minutes. - Each matching subnet contributes a weighted vote for its current upper-tier assignment. - The strongest signal determines the region’s primary upper tier. - Primary and fallback tiers are always placed in different Cloudflare points of presence to avoid a single-PoP failure eliminating both options. ## Practical Recommendation For public cloud origins behind anycast or regional unicast IPs, configure the correct cloud region hint through the dashboard, API, or Terraform. This lets Smart Tiered Cache retain a single, nearby primary tier while maintaining a separate fallback, improving cache efficiency and avoiding unnecessary cross-region traffic.