CDN routing to US instead of São Paulo causing latency issues.

9 replies
Last updated: Sep 16, 2022
Hi all, cdn questionif i call this cdn url
scp71evy.apicdn.sanity.io from NYC US and Sao Paolo Brazil the cdn call goes to US datacenter ? i saw sanity has CDN datacenter in Sao Paolo
AI Update

Great question about Sanity's CDN routing! Based on the API CDN documentation, here's how it works:

Yes, Sanity does have a CDN location in São Paulo, Brazil, and the CDN will intelligently route your requests to the closest available location.

According to the docs, Sanity currently has CDN locations in:

South America:

  • São Paulo, Brazil

North America:

  • Oregon, United States
  • Iowa, United States
  • Northern Virginia, United States

Plus locations in Asia, Oceania, and Europe

When you call [projectid].apicdn.sanity.io from NYC and São Paulo, the requests should be routed to the geographically nearest CDN location:

  • From NYC: Your request will likely hit one of the US datacenters (Northern Virginia, Iowa, or Oregon)
  • From São Paulo: Your request should be routed to the São Paulo CDN location

Additionally, Sanity uses a short-lived global CDN (powered by Fastly) in front of their own CDN infrastructure. This global CDN has points of presence on all continents and helps with edge optimization and routing.

The routing is automatic based on geographic proximity and network conditions - you don't need to configure anything. The CDN uses intelligent routing to ensure low latency and fast load times for users worldwide.

One thing to note: The global CDN layer doesn't cache private datasets or queries using the POST method, but it still helps with routing and performance optimization.

Hi User. I can check into this; would you mind confirming where you’re seeing that the call goes to the US instead of São Paulo?
hi, nice to meet you!let me help with this, I am the one in Sao Paulo...
👋
if I'm getting it right, the IP 34.102.168.221 is in Kansas City
My colleague was looking into something like this, so I’ll check on the work he did and get back to you, but I believe it’s some sort of IP aliasing (I’m not sure the exact term for it). We can see it’s likely at play here because a signal couldn’t get from São Paulo to Kansas City and back in 9 ms.
I’ll follow up shortly once I have some specifics.
Thanks
great point, 9ms is ultra fast
yes globally available ip addresses wreck havoc with whois lookups.
You can see the region indirectly by inferring from clustername here:

$ curl -XGET -I  <https://scp71evy.apicdn.sanity.io> -H"X-debug: true"
HTTP/2 200
date: Fri, 16 Sep 2022 07:06:28 GMT
content-type: application/json; charset=utf-8
content-length: 19
clustername: kubernetes02-eu-w1-01
grace: 1200.000
x-sanity-orig-cache-control:
x-sanity-beresp-ttl: 0.000
x-varnish: 351237158
x-sanity-age: 0
x-served-by: varnish-2
x-cache: MISS
vary: origin
accept-ranges: bytes
via: 1.1 varnish (Varnish/6.0), 1.1 google
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

kubernetes02-eu-w1-01
is GCP europe-west1, aka Belgium.You should see
kubernetes02-sa-e1-01
which is GCP southamerica-east1, aka Sao Paolo.

We have to revisit the documentation for this somehow I think, it’s such an easy assumption to make that whois is accurate.
thanks a lot User and User, all clear 👍I see the clustername referring to "south america" from my end

curl -XGET -I <https://scp71evy.apicdn.sanity.io> -H"X-debug: true"
HTTP/2 200 
date: Fri, 16 Sep 2022 13:03:48 GMT
content-type: application/json; charset=utf-8
content-length: 19
clustername: kubernetes02-sa-e1-01
grace: 1200.000
x-sanity-orig-cache-control: 
x-sanity-beresp-ttl: 0.000
x-varnish: 16686871
x-sanity-age: 0
x-served-by: varnish-1
x-cache: MISS
vary: origin
accept-ranges: bytes
via: 1.1 varnish (Varnish/6.0), 1.1 google
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?